Cloning Debian Linux

Sometimes we need to clone a Linux system for the following reason :

  • Install new Linux server with the same software level as existing one.
  • Moving the Linux operating system to the server hardware.
  • Change the root disk to the bigger one.

This article will show you how to move a running Debian Linux system to larger disk. In this how-to document I will use the following Debian version :

root@debian01:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 7.1 (wheezy)
Release:    7.1
Codename:   wheezy
root@debian01:~#

Lets start with examining the existing Linux system.

  • To check the hostname and kernel version we can use uname -a command as shown below :
    root@debian01:~# uname -a
    Linux debian01 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1+deb7u1 i686 GNU/Linux
    root@debian01:~#
  • To check mounted filesystem we can use df command as shown below :
    root@debian01:~# df -h
    Filesystem                                              Size  Used Avail Use% Mounted on
    rootfs                                                   19G  1.3G   17G   7% /
    udev                                                     10M     0   10M   0% /dev
    tmpfs                                                   406M  268K  406M   1% /run
    /dev/disk/by-uuid/9cd78397-4505-4c80-bddb-703543cdc46f   19G  1.3G   17G   7% /
    tmpfs                                                   5.0M     0  5.0M   0% /run/lock
    tmpfs                                                   987M     0  987M   0% /run/shm
    root@debian01:~#

    From the output we can see that, all directory stored under root filesystem. It didn’t separate directory like /boot, /var, or even /home. This information will affect the way we clone the disk to the new disks. We will talk about this later when we setup the partition on the new disk.

  • To check the partition layout on the existing disk we can use fdisk command :
    root@debian01:~# fdisk -l
    
    Disk /dev/sda: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00029de3
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        2048    40136703    20067328   83  Linux
    /dev/sda2        40138750    41940991      901121    5  Extended
    /dev/sda5        40138752    41940991      901120   82  Linux swap / Solaris
    root@debian01:~#
  • To check the partition type on existing disk we can use blkid command. In the following command, we can see that existing disk only consist of 2 partition : root & swap. Root partition uses ext4 filesystem.
    root@debian01:~# blkid
    /dev/sda5: UUID="5e43e27b-038a-45e2-bf84-2f31105b63a0" TYPE="swap" 
    /dev/sda1: UUID="9cd78397-4505-4c80-bddb-703543cdc46f" TYPE="ext4" 
    root@debian01:~#
  • To check active network configuration we can use ifconfig command as shown below :
    root@debian01:~# ifconfig -a
    eth0      Link encap:Ethernet  HWaddr 08:00:27:10:f3:d2  
              inet addr:192.168.10.62  Bcast:192.168.10.255  Mask:255.255.255.0
              inet6 addr: fe80::a00:27ff:fe10:f3d2/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:433 errors:0 dropped:0 overruns:0 frame:0
              TX packets:170 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:94304 (92.0 KiB)  TX bytes:23369 (22.8 KiB)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    root@debian01:~#

So lets move on by attach the new disk to the system. In this case I use a disk with bigger size than the existing root disk. Depends on the server itself, we can instantly attaching the new disk or it probably require reboot to let the system recognize the new disk. To check whether the new disk already attached we can use the fdisk command as shown below :

root@debian01:~# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00029de3

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    40136703    20067328   83  Linux
/dev/sda2        40138750    41940991      901121    5  Extended
/dev/sda5        40138752    41940991      901120   82  Linux swap / Solaris

Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table
root@debian01:~#

Before able to use new disk (/dev/sdb) as clone target, we need to prepare its partition first. We will use fdisk command to prepare the partition, below is the step-by-step guide to use fdisk :

  1. Start by invoking the fdisk command on /dev/sdb as shown below :
    root@debian01:~# fdisk /dev/sdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0x9c5d68fe.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.
    
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
    
    Command (m for help):
  2. Type p and press Enter to see the existing partition layout :
    Command (m for help): p
    
    Disk /dev/sdb: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9c5d68fe
    
       Device Boot      Start         End      Blocks   Id  System
    
    Command (m for help):

    Since the disk doesn’t have any partition at all then it shows empty partition layout. If there is any partition in the disk, we better delete it first by typing d (as for delete).

  3. To start create a partition on the disk type n as in “new partition”. Then we must decide whether we want to create primary or extended partition type. In this sample I choose to create primary partition type.
    Command (m for help): n
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p): p
    Partition number (1-4, default 1): 
    Using default value 1
    First sector (2048-83886079, default 2048): 
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-83886079, default 83886079): +15G
    
    Command (m for help):

    We need to define 3 value for each partition, they are :

    • Partition number : this will define the order of each partition, it define the name of partition later (/dev/sda1, /dev/sdb2, etc, etc).
    • First sector : this define the starting point of the partition. We can see that the whole disk consist of number of sectors start from sector number 2048–83886079. Logically we start from the beginning of the disk, sector 2048.
    • Last sector : last sector will define how big the partition will be. Since defining the partition using sector unit will be difficult, fdisk will let us define the size using human-readable size unit like K (for kilobyte), M (for Megabyte), or G (for Gigabyte). Just remember to start the value with + sign. In the example above, I choose to create 15G partition.
  4. Print the parition layout to verify the first partition created successfully :
    Command (m for help): p
    
    Disk /dev/sdb: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9c5d68fe
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048    31459327    15728640   83  Linux
    
    Command (m for help):
  5. Then we need to create second partition with 4GB size, we will use this partition as swap partition.
    Command (m for help): n
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): 
    Using default response p
    Partition number (1-4, default 2): 
    Using default value 2
    First sector (31459328-83886079, default 31459328): 
    Using default value 31459328
    Last sector, +sectors or +size{K,M,G} (31459328-83886079, default 83886079): +4G
    
    Command (m for help):

    See that the first sector now started from sector number 31459328. fdisk already know that the first partition will ended on 31459327 so the next available space will start on 31459328.

  6. Print the parition layout to verify the second partition created successfully :
    Command (m for help): p
    
    Disk /dev/sdb: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9c5d68fe
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048    31459327    15728640   83  Linux
    /dev/sdb2        31459328    39847935     4194304   83  Linux
    
    Command (m for help):
  7. I want to separate the /home as separate partition, so I create the 3rd partition and assign the rest available space to that.
    Command (m for help): n
    Partition type:
       p   primary (2 primary, 0 extended, 2 free)
       e   extended
    Select (default p): p
    Partition number (1-4, default 3): 
    Using default value 3
    First sector (39847936-83886079, default 39847936): 
    Using default value 39847936
    Last sector, +sectors or +size{K,M,G} (39847936-83886079, default 83886079): 
    Using default value 83886079
    
    Command (m for help):
  8. Print the partition again to verify all partition already correct :
    Command (m for help): p
    
    Disk /dev/sdb: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9c5d68fe
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048    31459327    15728640   83  Linux
    /dev/sdb2        31459328    39847935     4194304   83  Linux
    /dev/sdb3        39847936    83886079    22019072   83  Linux
    
    Command (m for help):
  9. Then we need to toggle bootable flag on the 1st partition since it act as root partition which contains /boot directory. Type a to start assign the bootable flag and then later type 1 to choose partition number 1.
    Command (m for help): a
    Partition number (1-4): 1
    
    Command (m for help): p
    
    Disk /dev/sdb: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9c5d68fe
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1   *        2048    31459327    15728640   83  Linux
    /dev/sdb2        31459328    39847935     4194304   83  Linux
    /dev/sdb3        39847936    83886079    22019072   83  Linux
    
    Command (m for help):

    If the partition already marked as bootable, then you can see the * sign in that partition.

  10. To make the changes permanently we need to type w as in “write into partition table” :
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    root@debian01:~#

After have the partition setup, we need to create the filesystem on top of it. In this example, we will use ext3 filesystem on partition 1 & 3. Also we need to activate partition number 2 as swap partition. To create the ext3 filesystem, we will use mkfs.ext3 command as shown in the following sample :

root@debian01:~# mkfs.ext3 /dev/sdb1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
983040 inodes, 3932160 blocks
196608 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4026531840
120 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

root@debian01:~# mkfs.ext3 /dev/sdb3
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1376256 inodes, 5504768 blocks
275238 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
168 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

root@debian01:~#

To activate the second partition as swap we will use mkswap command as shown below :

root@debian01:~# mkswap /dev/sdb2
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=c891f223-4912-4c4d-adbc-0158c89b8aff
root@debian01:~#

Once filesystem created, then we can mount the partition as shown on the following example :

root@debian01:~# mkdir /media/newroot
root@debian01:~# mkdir /media/newhome
root@debian01:~# mount /dev/sdb1 /media/newroot/
root@debian01:~# mount /dev/sdb3 /media/newhome/

We will use rsync command to do data synchronization between old disk to the new one. If you don’t have rsync installed on your system, then go install it first. Here is the sample installing rsync in Debian-based Linux distribution :

root@debian01:~# apt-get install rsync
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  rsync
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 357 kB of archives.
After this operation, 639 kB of additional disk space will be used.
Get:1 http://kambing.ui.ac.id/debian/ wheezy/main rsync i386 3.0.9-4 [357 kB]
Fetched 357 kB in 0s (397 kB/s)
Selecting previously unselected package rsync.
(Reading database ... 45874 files and directories currently installed.)
Unpacking rsync (from .../rsync_3.0.9-4_i386.deb) ...
Processing triggers for man-db ...
Setting up rsync (3.0.9-4) ...
update-rc.d: using dependency based boot sequencing
root@debian01:~#

Below is the sample how we use rsync to copy root partition to the new disk :

root@debian01:~# rsync -ar --exclude "/home" --exclude "/media/newroot" --exclude "/media/newhome" --exclude "/proc" --exclude "/sys" /* /media/newroot
root@debian01:~#

We will exclude some directory like /proc/ and /sys because both aren’t needed for this cloning process. We also excluding the partition of new disk as well.

We will copy /home/ partition to dedicated partition as well :

root@debian01:~# rsync -ar /home/* /media/newhome/
root@debian01:~#

Here is the status after synchronization process finished :

root@debian01:~# df -h
Filesystem                                              Size  Used Avail Use% Mounted on
rootfs                                                   19G  1.3G   17G   8% /
udev                                                     10M     0   10M   0% /dev
tmpfs                                                   406M  280K  406M   1% /run
/dev/disk/by-uuid/9cd78397-4505-4c80-bddb-703543cdc46f   19G  1.3G   17G   8% /
tmpfs                                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                                   987M     0  987M   0% /run/shm
/dev/sdb1                                                15G  1.3G   13G  10% /media/newroot
/dev/sdb3                                                21G  173M   20G   1% /media/newhome
root@debian01:~#

Then we will chroot-ing to the new root partition (/dev/sdb1 which mounted at /media/newroot at the moment). There are some step should be executed before we can chroot to the new root environment :

root@debian01:~# mkdir /media/newroot/proc
root@debian01:~# mkdir /media/newroot/dev
root@debian01:~# mkdir /media/newroot/sys
root@debian01:~# mount -o bind /dev /media/newroot/dev/
root@debian01:~# mount -t proc none /media/newroot/proc
root@debian01:~# mount -t sysfs none /media/newroot/sys
root@debian01:~# chroot /media/newroot

There are some steps will be executed from inside chroot environment :

  1. Before begin we need to verify that we already inside the chroot environment. The simplest task is using df -h command as shown below :
    root@debian01:/# df -h
    df: `/media/newhome': No such file or directory
    Filesystem                                              Size  Used Avail Use% Mounted on
    rootfs                                                   15G  1.3G   13G  10% /
    udev                                                     10M     0   10M   0% /dev
    devpts                                                   10M     0   10M   0% /dev/pts
    tmpfs                                                    15G  1.3G   13G  10% /run
    /dev/disk/by-uuid/9cd78397-4505-4c80-bddb-703543cdc46f   15G  1.3G   13G  10% /
    tmpfs                                                    15G  1.3G   13G  10% /run/lock
    tmpfs                                                    15G  1.3G   13G  10% /run/shm
    rpc_pipefs                                               15G  1.3G   13G  10% /var/lib/nfs/rpc_pipefs
    /dev/sdb1                                                15G  1.3G   13G  10% /
    udev                                                     10M     0   10M   0% /dev
    root@debian01:/# 
    root@debian01:/# pwd
    /
    root@debian01:/#

    See that there is no /dev/sdb1 & /dev/sdb3 being mounted, since we are already inside that /dev/sdb1.

  2. Then we need to modify /etc/fstab file. This file will define the list of partition that must be mounted during boot process. Copy the existing fstab file as backup.
    root@debian01:/# cd /etc/
    root@debian01:/etc# cp fstab fstab-orig

    Once have the backup, we can safely edit the fstab file. We need to change the disk identification so all partition information pointed to the new disk (/dev/sdb1). We can use blkid command to check the UUID of the new disk :

    root@debian01:/etc# blkid
    /dev/sda5: UUID="5e43e27b-038a-45e2-bf84-2f31105b63a0" TYPE="swap" 
    /dev/sda1: UUID="9cd78397-4505-4c80-bddb-703543cdc46f" TYPE="ext4" 
    /dev/sdb1: UUID="d9e6bd2b-8446-4f61-9636-9b078c0d966a" SEC_TYPE="ext2" TYPE="ext3" 
    /dev/sdb2: UUID="c891f223-4912-4c4d-adbc-0158c89b8aff" TYPE="swap" 
    /dev/sdb3: UUID="2cbe1cb3-1084-4229-92ff-847cd53e408a" SEC_TYPE="ext2" TYPE="ext3" 
    root@debian01:/etc#

    Then we can change the UUID informatio inside the fdisk file :

    root@debian01:/etc# vi fstab
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sda1 during installation
    UUID=d9e6bd2b-8446-4f61-9636-9b078c0d966a /               ext3    errors=remount-ro 0       1
    # swap was on /dev/sda5 during installation
    UUID=c891f223-4912-4c4d-adbc-0158c89b8aff none            swap    sw              0       0
    UUID=2cbe1cb3-1084-4229-92ff-847cd53e408a /home               ext3    defaults    0       1
    /dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
    root@debian01:/etc#

    We can compare the backup fstab with the one we just modified :

    root@debian01:/etc# diff -u fstab-orig fstab
    --- /etc/fstab  2013-09-21 11:03:34.000000000 +0700
    +++ /etc/fstab-orig 2013-09-21 10:57:55.000000000 +0700
    @@ -6,8 +6,7 @@
     #
     # <file system> <mount point>   <type>  <options>       <dump>  <pass>
     # / was on /dev/sda1 during installation
    -UUID=d9e6bd2b-8446-4f61-9636-9b078c0d966a /               ext3    errors=remount-ro 0       1
    +UUID=9cd78397-4505-4c80-bddb-703543cdc46f /               ext4    errors=remount-ro 0       1
     # swap was on /dev/sda5 during installation
    -UUID=c891f223-4912-4c4d-adbc-0158c89b8aff none            swap    sw              0       0
    -UUID=2cbe1cb3-1084-4229-92ff-847cd53e408a /home               ext3    defaults   0       1
    +UUID=5e43e27b-038a-45e2-bf84-2f31105b63a0 none            swap    sw              0       0
     /dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
    root@debian01:/etc#
  3. If we want to clone this new disk as new server then we probably need to modify the hostname & IP configuration. We can do it now :
    root@debian01:/etc# cat /etc/hostname 
    debian01
    root@debian01:/etc# vi /etc/hostname 
    debian01-new
    root@debian01:/etc#
  4. In this step we need to reinstall the boot loader into new disk’s MBR. In this example, system use GRUB boot loader so we will use the following command to reinstall the GRUB :
    root@debian01:/etc# update-grub
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-3.2.0-4-686-pae
    Found initrd image: /boot/initrd.img-3.2.0-4-686-pae
    done
    root@debian01:/etc# grub-install /dev/sdb
    Installation finished. No error reported.
    root@debian01:/etc#
  5. Exit the chroot environment :
    root@debian01:/etc# exit
    root@debian01:~# df -h
    Filesystem                                              Size  Used Avail Use% Mounted on
    rootfs                                                   19G  1.3G   17G   8% /
    udev                                                     10M     0   10M   0% /dev
    tmpfs                                                   406M  280K  406M   1% /run
    /dev/disk/by-uuid/9cd78397-4505-4c80-bddb-703543cdc46f   19G  1.3G   17G   8% /
    tmpfs                                                   5.0M     0  5.0M   0% /run/lock
    tmpfs                                                   987M     0  987M   0% /run/shm
    /dev/sdb1                                                15G  1.3G   13G  10% /media/newroot
    /dev/sdb3                                                21G  173M   20G   1% /media/newhome
    udev                                                     10M     0   10M   0% /media/newroot/dev
    root@debian01:~#

At this point we have successfully clone the complete Linux system to the new disk. We can shutdown the server and swap the disk or we can use the second disk (/dev/sdb) to boot another server.

root@debian01:~# shutdown -h now

Broadcast message from root@debian01 (pts/0) (Sat Sep 21 11:00:57 2013):

The system is going down for system halt NOW!
root@debian01:~#

If everything is right then system will be able to boot using the /dev/sdb :

$ ssh root@192.168.10.62
root@192.168.10.62's password: 
Linux debian01-new 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1+deb7u1 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Sep 21 11:06:54 2013
root@debian01-new:~# uname -a
Linux debian01-new 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1+deb7u1 i686 GNU/Linux
root@debian01-new:~# df -h
Filesystem                                              Size  Used Avail Use% Mounted on
rootfs                                                   15G  1.3G   13G  10% /
udev                                                     10M     0   10M   0% /dev
tmpfs                                                   406M  268K  406M   1% /run
/dev/disk/by-uuid/d9e6bd2b-8446-4f61-9636-9b078c0d966a   15G  1.3G   13G  10% /
tmpfs                                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                                   1.6G     0  1.6G   0% /run/shm
/dev/sda3                                                21G  173M   20G   1% /home
root@debian01-new:~# su - ttirtawi
ttirtawi@debian01-new:~$ pwd
/home/ttirtawi
ttirtawi@debian01-new:~$

See that the disk with UUID d9e6bd2b-8446-4f61-9636-9b078c0d966a is mounted as root now.

Congratulation you have your Linux live on the new disk now.

Illustration from : http://www.linux.org/resources/debian.11/

Cloning Debian Linux by Tedy Tirtawidjaja

Setup Dropbox Tanpa GUI

Dropbox adalah layanan berbagi komputasi awan (cloud service) untuk sarana berbagi data (file). Cara menggunakan Dropbox relatif sangat mudah :

  1. Pertama kita perlu membuat akun dulu di http://dropbox.com untuk mendapatkan username & password.
  2. Memasang aplikasi Dropbox di komputer kita, sebut saja ini sebagai Dropbox Client. Aplikasi Dropbox meminta kita untuk memasukkan username & password (yang kita sudah buat di tahap 1). Ini contoh tampilan di Windows 7 saat kita pertama kali mengaktifkan Dropbox :

  3. Setelah aplikasi terpasang, Dropbox akan membuat sebuah direktori (folder) dengan nama “Dropbox”. Aplikasi Dropbox akan otomatis mengunggah (upload) semua file yang ada dalam direktori Dropbox ke server Dropbox. Kita bisa sebut tahap ini sebagai tahap sinkronisasi data dengan Dropbox server.
  4. Bila proses sinkronisasi sudah selesai, semua berkas tadi bisa diakses melalui websitenya Dropbox.
  5. Lalu bila kita memasang aplikasi Dropbox di komputer lain (melakukan login dengan akun yang sama), Dropbox akan secara otomatis melakukan sinkronisasi berkas-berkas yang tadi. Sama halnya bila kita memasang Dropbox di ponsel seperti iPhone atau Android.

Dropbox mendukung banyak macam sistem operasi, artinya kita dengan mudah bisa mendapatkan aplikasi Dropbox (Dropbox Client) untuk Windows, Mac, Linux, IOS, Android, Windows Phone, Blackberry. Hampir semua tipe instalasi memerlukan tampilan grafis (seperti yang terlihat di gambar di atas). Nah saya baru tahu ternyata saya bisa juga menggunakan Dropbox di komputer yang tidak memiliki tampilan grafis atau GUI (graphihcal user interface). Cukup dengan menggunakan command line interface (CLI) saya dapat menginstal Dropbox. Perintahnya seperti berikut ini :

cd ~ && wget --no-check-certificate -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -

Dan ini contoh hasil yang diperoleh saat menggunakan perintah tadi :

[ttirtawi@puppet ~]$ cd ~ && wget --no-check-certificate -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -
--2013-09-06 13:09:48--  https://www.dropbox.com/download?plat=lnx.x86
Resolving www.dropbox.com... 199.47.216.170
Connecting to www.dropbox.com|199.47.216.170|:443... connected.
HTTP request sent, awaiting response... 302 FOUND
Location: https://dl-web.dropbox.com/u/17/dropbox-lnx.x86-2.0.26.tar.gz [following]
--2013-09-06 13:09:49--  https://dl-web.dropbox.com/u/17/dropbox-lnx.x86-2.0.26.tar.gz
Resolving dl-web.dropbox.com... 107.22.174.34
Connecting to dl-web.dropbox.com|107.22.174.34|:443... connected.
HTTP request sent, awaiting response... 302 FOUND
Location: https://dl.dropboxusercontent.com/u/17/dropbox-lnx.x86-2.0.26.tar.gz [following]
--2013-09-06 13:09:50--  https://dl.dropboxusercontent.com/u/17/dropbox-lnx.x86-2.0.26.tar.gz
Resolving dl.dropboxusercontent.com... 54.225.220.46
Connecting to dl.dropboxusercontent.com|54.225.220.46|:443... connected.
WARNING: cannot verify dl.dropboxusercontent.com's certificate, issued by `/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance CA-3':
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: 20197195 (19M) [application/x-tar]
Saving to: `STDOUT'

100%[================================================================>] 20,197,195   540K/s   in 38s     

2013-09-06 13:10:30 (513 KB/s) - `-' saved [20197195/20197195]

[ttirtawi@puppet ~]$

Instalasi Dropbox tadi akan membuat sebuah direktori baru (.dropbox-dist). Untuk mulai mengaktifkan Dropbox saya tinggal ketik perintah ini :

[ttirtawi@puppet ~]$ ~/.dropbox-dist/dropboxd &
[1] 32515
[ttirtawi@puppet ~]$ This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...

Nah karena belum ada informasi login apapun yang saya gunakan maka akan muncul tampilan peringatan seperti itu :

Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...

Saya tinggal gunakan web browser  untuk mengakses link yang disebutkan tersebut. Tentunya saya gunakan komputer lain tentunya karena server tadi tidak memiliki tampilan grafis. Link tersebut tampilannya seperti berikut ini :

Saya diminta untuk mengisikan password Dropbox saya. Tentu karena sebelumnya saya sudah login di web browser jadi yang muncul hanya tampilan Password. Setelah login akan muncul notifikasi “Your computer successfully linked to  your account” seperti pada gambar di bawah ini :

Secara otomatis di Terminal akan muncul notifikasi juga kalau akun Dropbox saya sudah sukses terinstal :

Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1426f8c8cc207d83def2dd2b7135d188 to link this machine.
Client successfully linked, Welcome Tedy!

[ttirtawi@puppet ~]$

Saya bisa cek proses Dropbox sudah aktif dengan perintah berikut ini :

[ttirtawi@puppet ~]$ ps -ef | grep drop
ttirtawi 32515 32034 18 13:16 pts/0    00:00:19 /home/ttirtawi/.dropbox-dist/dropbox
ttirtawi 32580 32034  0 13:17 pts/0    00:00:00 grep drop
[ttirtawi@puppet ~]$

Dropbox sudah aktif dan segera melakukan sinktronisasi data saya. Tidak lama setelah itu Dropbox mengirimkan email pemberitahuan juga seperti ini :

 

Versi OS di Ubuntu/Debian, Solaris 10, & OSX

Untuk melihat versi sistem operasi Ubuntu saya biasa gunakan perintah lsb_release -a seperti berikut ini :

ttirtawi@gbt733:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 12.10
Release:	12.10
Codename:	quantal
ttirtawi@gbt733:~$

Atau bisa tinggal lihat berkas /etc/lsb-release :

ttirtawi@gbt733:~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.10
DISTRIB_CODENAME=quantal
DISTRIB_DESCRIPTION="Ubuntu 12.10"
ttirtawi@gbt733:~$

Perintah yang sama bisa dipakai di distribusi Debian :

pasific:~# lsb_release -a
LSB Version:	core-2.0-ia32:core-2.0-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:core-3.2-ia32:core-3.2-noarch:cxx-3.0-ia32:cxx-3.0-noarch:cxx-3.1-ia32:cxx-3.1-noarch:cxx-3.2-ia32:cxx-3.2-noarch:desktop-3.1-ia32:desktop-3.1-noarch:desktop-3.2-ia32:desktop-3.2-noarch:graphics-2.0-ia32:graphics-2.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch:graphics-3.1-ia32:graphics-3.1-noarch:graphics-3.2-ia32:graphics-3.2-noarch:qt4-3.1-ia32:qt4-3.1-noarch
Distributor ID:	Debian
Description:	Debian GNU/Linux 5.0 (lenny)
Release:	5.0
Codename:	lenny
pasific:~#

Di Debian 7 informasi yang sama bisa diliat di berkas /etc/os-release seperti berikut ini :

ttirtawi@debian7:~$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"
ttirtawi@debian7:~$

Sementara di Solaris 10, versi OSnya bisa dilihat di berkas /etc/release seperti berikut ini :

$ cat /etc/release
                   Oracle Solaris 10 9/10 s10s_u9wos_14a SPARC
     Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
                            Assembled 11 August 2010
$ 

Agak sedikit berbeda di Mac OSX Mountain Lion, saya baru tahu 2 perintah berikut ini untuk melihat versi OS dari command line. Yang pertama adalah sw_vers :

ttirtawi@macmini:~$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.8.4
BuildVersion:	12E55
ttirtawi@macmini:~$

Sementara yang kedua adalah system_profiler :

ttirtawi@macmini:~$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: OS X 10.8.4 (12E55)
      Kernel Version: Darwin 12.4.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: macmini
      User Name: Tedy Tirtawidjaja (ttirtawi)
      Secure Virtual Memory: Enabled
      Time since boot: 2 days 4:36

ttirtawi@macmini:~$

List Hardware Mac via Command Line

Di Linux ada perintah lshw untuk menampilkan daftar perangkat yang terpasang, seperti ini tampilannya :

ttirtawi@gbt733:~$ sudo lshw -short
[sudo] password for ttirtawi: 
H/W path       Device     Class       Description
=================================================
                          system      Lenovo ()
/0                        bus         Mariana
/0/0                      memory      107KiB BIOS
/0/4                      processor   Intel(R) Atom(TM) CPU N270   @ 1.60GHz
/0/4/5                    memory      64KiB L1 cache
/0/4/0.1                  processor   Logical CPU
/0/4/0.2                  processor   Logical CPU
/0/e                      memory      2560MiB System Memory
/0/e/0                    memory      512MiB DIMM DDR2 Synchronous 533 MHz (1.9 ns)
/0/e/1                    memory      2GiB DIMM DDR2 Synchronous 533 MHz (1.9 ns)
/0/1                      processor   Intel(R) Atom(TM) CPU N270   @ 1.60GHz
/0/1/0.1                  processor   Logical CPU
/0/1/0.2                  processor   Logical CPU
/0/100                    bridge      Mobile 945GSE Express Memory Controller Hub
/0/100/2                  display     Mobile 945GSE Express Integrated Graphics Controller
/0/100/2.1                display     Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller
/0/100/1b                 multimedia  NM10/ICH7 Family High Definition Audio Controller
/0/100/1c                 bridge      NM10/ICH7 Family PCI Express Port 1
/0/100/1c/0    eth0       network     NetLink BCM5906M Fast Ethernet PCI Express
/0/100/1c.1               bridge      NM10/ICH7 Family PCI Express Port 2
/0/100/1c.2               bridge      NM10/ICH7 Family PCI Express Port 3
/0/100/1c.2/0  eth1       network     BCM4312 802.11b/g LP-PHY
/0/100/1d                 bus         NM10/ICH7 Family USB UHCI Controller #1
/0/100/1d.1               bus         NM10/ICH7 Family USB UHCI Controller #2
/0/100/1d.2               bus         NM10/ICH7 Family USB UHCI Controller #3
/0/100/1d.3               bus         NM10/ICH7 Family USB UHCI Controller #4
/0/100/1d.7               bus         NM10/ICH7 Family USB2 EHCI Controller
/0/100/1e                 bridge      82801 Mobile PCI Bridge
/0/100/1f                 bridge      82801GBM (ICH7-M) LPC Interface Bridge
/0/100/1f.2               storage     82801GBM/GHM (ICH7-M Family) SATA Controller [IDE mode]
/0/100/1f.3               bus         NM10/ICH7 Family SMBus Controller
/0/2           scsi0      storage     
/0/2/0.0.0     /dev/sda   disk        80GB Hitachi HTS54328
/0/2/0.0.0/1   /dev/sda1  volume      11GiB EXT3 volume
/0/2/0.0.0/3   /dev/sda3  volume      972MiB Linux swap volume
/0/2/0.0.0/4   /dev/sda4  volume      61GiB EXT4 volume
/0/3           scsi2      storage     
/0/3/0.0.0     /dev/sdb   disk        1TB SCSI Disk
/0/3/0.0.0/1   /dev/sdb1  volume      931GiB EXT4 volume
/0/5           scsi3      storage     
/0/5/0.0.0     /dev/sdc   disk        SCSI Disk
ttirtawi@gbt733:~$ 

Di Mac saya baru tahu ada perintah system_profiler yang sama fungsinya seperti lshw. Misalnya untuk menampilkan ringkasan perangkat keras Mac kita bisa menggunakan perintah seperti ini :

ttirtawi@macbook-air:~$ system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Air
      Model Identifier: MacBookAir5,1
      Processor Name: Intel Core i5
      Processor Speed: 1.7 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Memory: 4 GB
      Boot ROM Version: MBA51.00EF.B02
      SMC Version (system): 2.4f17
      Serial Number (system): C02HRDWUDRV7
      Hardware UUID: CBAEA018-C28C-5BAA-861F-D01CF05E141D

ttirtawi@macbook-air:~$ 

Atau untuk menampilkan daftar yang lebih lengkap bisa dipakai perintah ini :

ttirtawi@macbook-air:~$ system_profiler -detailLevel mini
Audio:

    Intel High Definition Audio:

      Audio ID: 85

        Headphone:

          Connection: Combination Output

        Speaker:

          Connection: Internal

        Internal Microphone:

          Connection: Internal

        External Microphone / iPhone Headset:

          Connection: Combination Output

        HDMI / DisplayPort Output:

          Connection: Display

    Devices:

        Built-in Microphone:

          Default Input Device: Yes
          Input Channels: 2
          Manufacturer: Apple Inc.
          Current SampleRate: 44100
          Transport: Built-in

        Built-in Output:

          Default Output Device: Yes
          Default System Output Device: Yes
          Manufacturer: Apple Inc.
          Output Channels: 2
          Current SampleRate: 44100
          Transport: Built-in

        LogMeInSoundDriver:

          Input Channels: 2
          Manufacturer: LogMeIn, Inc.
          Output Channels: 2
          Current SampleRate: 44100
          Transport: Unknown

        Soundflower (2ch):

          Input Channels: 2
          Manufacturer: ma++ ingalls for Cycling '74
          Output Channels: 2
          Current SampleRate: 44100
          Transport: Unknown

        Soundflower (64ch):

          Input Channels: 64
          Manufacturer: ma++ ingalls for Cycling '74
          Output Channels: 64
          Current SampleRate: 44100
          Transport: Unknown

Bluetooth:

      Apple Bluetooth Software Version: 4.1.3f3 11349
      Hardware Settings:
          Manufacturer: Broadcom
          Firmware Version: v100 c5052
          Vendor ID: 0x5ac
          Product ID: 0x821f
      Devices (Paired, Favorites, etc):
          Tedy Tirtawidjaja’s Keyboard:
              Type: Keyboard
              Firmware Version: 0x50
              Services: Apple Wireless Keyboard
              Manufacturer: Apple (0x3, 0x31c)
              Vendor ID: 0x5ac
              Product ID: 0x255
              EDR Supported: No
              eSCO Supported: No
          Tedy Tirtawidjaja’s Trackpad:
              Type: Trackpad
              Firmware Version: 0x160
              Services: Apple Wireless Trackpad
              Manufacturer: Apple (0x3, 0x31c)
              Vendor ID: 0x5ac
              Product ID: 0x30e
              EDR Supported: No
              eSCO Supported: No
          Apple Magic Mouse:
              Type: Mouse
              Firmware Version: 0x306
              Services: Apple Magic Mouse
              Manufacturer: Apple (0x3, 0x31c)
              Vendor ID: 0x5ac
              Product ID: 0x30d
              EDR Supported: No
              eSCO Supported: No

Diagnostics:

    Power On Self-Test:

      Last Run: 3/18/13 5:35 PM
      Result: Passed

Graphics/Displays:

    Intel HD Graphics 4000:

      Chipset Model: Intel HD Graphics 4000
      Type: GPU
      Bus: Built-In
      VRAM (Total): 512 MB
      Vendor: Intel (0x8086)
      Device ID: 0x0166
      Revision ID: 0x0009
      Displays:
        HP x2301:
          Resolution: 1920 x 1080 @ 60 Hz
          Pixel Depth: 32-Bit Color (ARGB8888)
          Display Serial Number: 3CM223011Y  
          Main Display: Yes
          Mirror: Off
          Online: Yes
          Rotation: Supported

Hardware:

    Hardware Overview:

      Model Name: MacBook Air
      Model Identifier: MacBookAir5,1
      Processor Name: Intel Core i5
      Processor Speed: 1.7 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Memory: 4 GB
      Boot ROM Version: MBA51.00EF.B02
      SMC Version (system): 2.4f17

Memory:

    Memory Slots:

      ECC: Disabled

        BANK 0/DIMM0:

          Size: 2 GB
          Type: DDR3
          Speed: 1600 MHz
          Status: OK
          Manufacturer: 0x80AD
          Part Number: 0x484D54333235533643465238412D50422020

        BANK 1/DIMM0:

          Size: 2 GB
          Type: DDR3
          Speed: 1600 MHz
          Status: OK
          Manufacturer: 0x80AD
          Part Number: 0x484D54333235533643465238412D50422020

Network:

    Wi-Fi:

      Type: AirPort
      Hardware: AirPort
      BSD Device Name: en0
      Has IP Assigned: Yes
      Service Order: 2


...
...
...
...
...

Format USB Flash Disk Dengan fdisk

DSCN7470-edit

Biasanya sebelum dapat menggunakan USB flash disk kita perlu melakukan format dulu. Memformat sebuah flash disk gunanya untuk membuat partisi & file system. Di Windows kita bisa klik kanan pada drive yang bersangkutan lalu pilih menu format. Di Mac ada Disk Utility yang bisa membantu kita memformat USB flash disk. Di Linux ada gparted, dengan tampilan GUI yang mudah digunakan. Sayangnya gparted memerlukan tampilan GUI & tidak semua distro Linux menyertakan gparted pada paket instalasi standarnya. Yang umumnya pasti ada di Linux adalah command line tools fdisk. Tulisn ini adalah contoh singkat cara menggunakan fdisk untuk memformat sebuah USB flash disk.

Misalnya saya baru menancapkan flash disk pada sebuah port USB. Di Ubuntu saya bisa cek di syslog bahwa Ubuntu mendeteksi USB tersebut sebagai /dev/sdb1. Pada contoh ini USB saya sudah memiliki partisi FAT32. Baik syslog maupun dmesg menginformasikan hal yang sama seperti di bawah ini :

ttirtawi@x220:~$ dmesg
[384141.590009] usb 2-1.2: >new high-speed USB device number 5 using ehci_hcd
[384141.682602] usb 2-1.2: >New USB device found, idVendor=0781, idProduct=5571
[384141.682612] usb 2-1.2: >New USB device strings: Mfr=1, Product=2, SerialNumber=3
[384141.682618] usb 2-1.2: >Product: Firebird USB Flash Drive
[384141.682623] usb 2-1.2: >Manufacturer: SanDisk
[384141.682628] usb 2-1.2: >SerialNumber: 4C532000051129104532
[384141.683662] scsi9 : usb-storage 2-1.2:1.0
[384142.681068] scsi 9:0:0:0: >Direct-Access     SanDisk  Cruzer Fit       1.26 PQ: 0 ANSI: 5
[384142.683601] sd 9:0:0:0: >Attached scsi generic sg1 type 0
[384142.685096] sd 9:0:0:0: >[sdb] 31266816 512-byte logical blocks: (16.0 GB/14.9 GiB)
[384142.686962] sd 9:0:0:0: >[sdb] Write Protect is off
[384142.686975] sd 9:0:0:0: >[sdb] Mode Sense: 43 00 00 00
[384142.687969] sd 9:0:0:0: >[sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[384142.716570]  sdb: sdb1
[384142.721248] sd 9:0:0:0: >[sdb] Attached SCSI removable disk
ttirtawi@x220:~$

Misalnya saya ingin menghapus partisi yang sudah ada & melakukan format lagi pada USB flash disk ini. Ini contoh cara menggunakan fdisk & keterangannya :

ttirtawi@x220:~$ sudo fdisk /dev/sdb

Command (m for help): p    ##### p = menampilkan partisi yang sudah ada (terlihat 1 partisi, sdb1)

Disk /dev/sdb: 16.0 GB, 16008609792 bytes
255 heads, 63 sectors/track, 1946 cylinders, total 31266816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               2    31266815    15633407    b  W95 FAT32

Command (m for help): d     ##### d = delete partisi yang ada  
Selected partition 1        ##### karena cuma ada 1 partisi maka fdisk otomatis menghapus partisi itu

Command (m for help): p     ##### p = menampilkan partisi lagi (kali ini kosong tidak terlihat ada partisi)

Disk /dev/sdb: 16.0 GB, 16008609792 bytes
255 heads, 63 sectors/track, 1946 cylinders, total 31266816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n     ##### n = membuat partisi baru    
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p       ##### p di sini maksudnya primary partition.
Partition number (1-4, default 1): 1     #####  angka 1 maksudnya nomor partisi
First sector (2048-31266815, default 2048):  
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-31266815, default 31266815): 
Using default value 31266815

Command (m for help): w     ##### w = write / tulis partisi tersebut ke dalam flash disk
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
ttirtawi@x220:~$

Untuk dapat menggunakan flash disk tadi untuk menyimpan data, saya harus membuat file system pada partisi baru yang sudah saya buat. Perintahnya bisa dengan menggunakan mkfs. Karena saya ingin membuat file system FAT42 maka saya gunakan perintah mkfs.vfat seperti berikut ini :

ttirtawi@x220:~$ sudo mkfs.vfat /dev/sdb1
mkfs.vfat 3.0.13 (30 Jun 2012)
ttirtawi@x220:~$

Karena saya tidak memberi opsi apa-apa pada perintah mkfs.vfat, maka partisi tersebut akan menggunakan nama volume yang acak. Ini terlihat pada saat Ubuntu secara otomatis melakukan mounting pada partisi tersebut. Ini contoh tampilan USB (partisi sdb1) yang sudah ter-mount :

ttirtawi@x220:~$ df -h | grep sdb1
/dev/sdb1        15G  541M   15G   4% /media/E827-5B17
ttirtawi@x220:~$

Untuk bisa menamai volume tadi bisa ditambahkan opsi -n seperti ini :

ttirtawi@x220:~$ sudo mkfs.vfat -n "USB-TEDY" /dev/sdb1
mkfs.vfat 3.0.13 (30 Jun 2012)
ttirtawi@x220:~$

Maka saat sudah di-mount tampilannya menjadi seperti ini :

ttirtawi@x220:~$ df -h | grep sdb1
/dev/sdb1        15G  8.0K   15G   1% /media/ttirtawi/USB-TEDY
ttirtawi@x220:~$