Managing Partitions
Tasks
- In the remaining disks space on your server hard disk, add a 1GiB paetition.
- Do this in such a way that it's possible to add more partitions later.
- Format partition with ex4 file system and set label Dbfiles on the partition.
- Mount this partition persistently on the directory /dbfiles, using partition label.
Solution
1. Add a 1GiB partition
There are two steps here:
-
Identify the remaining disk space:
Determine the available disk space and identify where you want to create the new partition. This typically involves using tools like
fdisk,parted, orgpartedto manage disk partitions.Let's assume you have identified an unallocated space on
/dev/sdb. -
Create a new partition:
Use
fdiskorpartedto create a new partition.sudo fdisk /dev/sdbNotes:
- Type
nfor a new partition. - Choose the default or specify the partition type (primary or extended).
- Specify the partition size as 1GiB (e.g.,
+1G). - Write changes (
w) and exit (q).
- Type
2. Format partition and set label
-
Format the partition with ext4:
Format the newly created partition
/dev/sdb1with ext4 filesystem:sudo mkfs.ext4 /dev/sdb1 -
Set label on the partition:
Assign the label Dbfiles to the partition
/dev/sdb1usinge2labelcommand:sudo e2label /dev/sdb1 Dbfiles
3. Configure persistent mounting
-
Create a mount point for the partition:
Create a directory where you want to mount the partition. In this case, create
/dbfiles:sudo mkdir /dbfiles -
Configure persistent mount using partition label:
Add an entry to
/etc/fstabfor persistent mounting. Edit/etc/fstabwith your preferred text editor:sudo nano /etc/fstabAdd the following line at the end of the file:
LABEL=Dbfiles /dbfiles ext4 defaults 0 2Notes:
LABEL=Dbfiles: Mount by label Dbfiles./dbfiles: Mount point directory.ext4: Filesystem type.defaults: Mount options (default options).0 2: Filesystem check order during boot (0 = skip, 2 = check after root filesystem).
-
Mount the partition persistently:
Mount all filesystems listed in
/etc/fstab:sudo mount -a -
Verify persistent mount:
Check if the partition
/dev/sdb1is mounted on/dbfiles:df -h /dbfiles