Formating Disk in Linux¶
First Part: Disk formatting tutorial
- In each of your VM, please look at the device disk list.
$ cat /proc/partitions|grep vd*
- Please save the output above in "hasil.txt" by using:
$ cat /proc/partitions|grep vd >> hasil.txt
- vda, vdb, vdc, vdd, vde, and vdf are well known as block device file. Those file are representation of I/O devices such as hard disk, flash disk, memory card, and CD/DVD ROM. Those devices write the data in block in hard disk. Block is byte sequence with a particular size like 512 bytes or 4 kilobytes.
- Block device's file is located in /dev. Please check for vda's file in /dev
$ ls -lah /dev/vda*
- Please save the output into hasil.txt.
$ ls -lah /dev/vda* >> hasil.txt
- Any partition which had been formatted should be mounted into a directory so it can be used.
Use the following command to find out where /dev/vda1 is mounted.
$ cat /proc/mounts | grep vda1
- Plase save the output into hasil.txt.
$ cat /proc/mounts | grep vda1 >> hasil.txt
- Now create another disk from any other disk than vda. Each student should use different disk for their own task (please discuss it with your group). After doing so, follow next instructions and REPLACE any vdb with your own disk (vdb, vdc, vdd, vde, or vdf) in every commands.
- Use fdisk command to create new partition in your disk.
$ sudo fdisk /dev/vdb
TIP: If you need to cancel/quit from fdisk command, insert q.
- Create new primary partition by inserting n and then p into fdisk command.
- Insert default value for partition number, first sector, and last sector because we will turn the whole device into one partition.
- Check your partition status by inserting p.
Then write your partition changes by inserting w.
- And then, format your newly created partition into using ext4 file system and add LATIHAN as disk label.
$ sudo mkfs.ext4 -L LATIHAN /dev/vdb1
- Afterwards, please mount the partition and go to the partition in Terminal. Remember to replace vdb with your assigned disk.
$ sudo mkdir /mnt/vdb1 $ sudo mount /dev/vdb1 /mnt/vdb1
- Please download Tiny Core iso from Kambing into your new partition.
$ wget http://kambing.ui.ac.id/tinycorelinux/4.x/x86/release/TinyCore-current.iso $ sudo cp TinyCore-current.iso /mnt/vdb1/
- Write the content of /mnt/vdb1 into hasil.txt. Remember to replace vdb with your assigned disk.
$ ls -al /mnt/vdb1 >> hasil.txt $ sudo /sbin/blkid | grep /dev/vdb >> hasil.txt
- Please view the content of hasil.txt.
$ cat hasil.txt
- Make sure every person in your group already done the first part.
- Repeat previous steps to re-format one of any disk (vdb/vdc/vdd/vde/vdf). Please discuss it within your group.
Change the output destination into hasil-tugas.txt instead of hasil.txt.
As example, if you use vdb then re-format vdb into 2 partitions with these specifications.
- vdb1: type: primary, partition number: 1, size: 10M, file system: ext3, label: [GROUP_NAME].
- vdb2: type: primary, partition number: 2, size: 9.5M, file system: ext3, label: [CLASS]
Replace [GROUP_NAME] with your group name and [CLASS] with your class code (e.g. A160).
- Bonus (5 points): format vdb2 with type: extended logical.
TIP: If you want to delete any partition, find help with m in fdisk command.