Cara Membuat Partisi CentOS 7 Via Command Line
|Secara teknis setingan partisi bisa dikerjakan pada awal installasi OS, namun juga bisa dilakukan setelah installasi OS selesai. Artikel ini akan membahas bagaimana cara membuat partisi pada centOS 7 melalui command line.
Pertama cek sisa space menggunakan perintah berikut
# fdisk -l
Output
Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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 label type: dos Disk identifier: 0x000623f2 Device Boot Start End Blocks Id System /dev/vda1 2048 2099199 1048576 82 Linux swap / Solaris /dev/vda2 * 2099200 83883647 40892224 83 Linux Disk /dev/loop0: 1658 MB, 1658847232 bytes, 3239936 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
Dari hasil diatas tertulis bahwa ada sisa space dengan ukuran 10GB (104857600 sectors), selanjutnya buat partisi baru pada /dev/vda menggunakan sisa partisi tersebut sehingga nanti akan muncul partisi baru. Jalankan perintah dibawah ini
# fdisk /dev/vda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): m (Ketik m, untuk melihat perintah yang bisa digunakan) Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n (setelah itu pilih n, untuk membuat partisi baru) Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p (pilih p untuk default/pripary, pilih e untuk extended) Partition number (3,4, default 3): 3 (pilih 3 untuk default) First sector (83883648-104857599, default 83884032): 83884032 (sector pilih default saja) Last sector, +sectors or +size{K,M,G} (83884032-104857599, default 104857599): 104857599 (sector pilih default saja) Partition 3 of type Linux and of size 10 GiB is set Command (m for help): w (ketik w untuk membaca prtisi yang sudah kita buat) The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
Jika sudah maka jalankan perintah partprobe agar OS mendeteksi tabel partisi baru yang sudah kita buat. Jika sudah cek apakah partisi sudah berhasil atau belum dengan perintah dibawah ini
# fdisk -l Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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 label type: dos Disk identifier: 0x000623f2 Device Boot Start End Blocks Id System /dev/vda1 2048 2099199 1048576 82 Linux swap / Solaris /dev/vda2 * 2099200 83883647 40892224 83 Linux /dev/vda3 83884032 104857599 10486784 83 Linux (partisi baru dengan nama /dev/vda3 ukuran 10GB) Disk /dev/loop0: 1658 MB, 1658847232 bytes, 3239936 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
Dari output diatas kita sudah berhasil melakukan partisi baru dengan nama /dev/vda3 , setelah itu format dengan perintah berikut
# mkfs.ext4 /dev/vda3 mke2fs 1.42.9 (28-Dec-2013) warning: 256 blocks unused. Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 656640 inodes, 2621440 blocks 131071 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2151677952 80 block groups 32768 blocks per group, 32768 fragments per group 8208 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Setelah itu buat folder baru untuk mount partisi yang sudah dibuat sebelumnya, saya akan mount /dev/vda3 ke /home2 maka buat folder dahulu
# mkdir -p /home2
Lalu mount dengan perintah berikut
# mount /dev/vda3 /home2
Kemudian cek apakah sudah berhasil atau belum dengan perintah df -h.
# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda2 39G 7,2G 30G 20% / devtmpfs 1,4G 0 1,4G 0% /dev tmpfs 1,4G 4,0K 1,4G 1% /dev/shm tmpfs 1,4G 49M 1,4G 4% /run tmpfs 1,4G 0 1,4G 0% /sys/fs/cgroup /dev/loop0 1,5G 2,4M 1,5G 1% /tmp tmpfs 285M 0 285M 0% /run/user/0 /dev/vda3 9,8G 37M 9,2G 1% /home2 (partisi baru sudah terbaca)
Lalu agar partisi kita tidak hilang ketika dilakukan reboot server, maka tambahkan partisi baru pada /etc/fstab seperti dibawah ini
# nano /etc/fstab # # /etc/fstab # Created by anaconda on Fri Jul 6 14:58:33 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=08b8d935-4ab8-4226-b536-d953f804927b / ext4 usrjquota=quota.user,jqfmt=vfsv0 1 1 UUID=bfc73567-e043-479b-afe0-10e290d53008 swap swap defaults 0 0 /usr/tmpDSK /tmp ext3 defaults,noauto 0 0 /dev/vda3 /home2 ext4 defaults 1 2
Jika sudah ditambahkan save, kemudian lakukan reboot lalu silahkan cek ulang menggunakan perintah df -h.
Demikian cara membuat partisi pada centOS 7 melalui command line. Mudah bukan ? Selamat mencoba :p