# become root
su - root
# or
sudo bash

# mount folderA into folderB
# the data of folderA will be available via folderB
echo "/folderA /folderB none bind 0 0" >> /etc/fstab
# mount all mounts defined in fstab
mount -a

lsblk; # list block devices, checkout what harddisks are there
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 47.7G 0 disk
└─sda1 8:1 0 23.9G 0 part /
sr0 11:0 1 1024M 0 rom

# assume the new partition will be created on the first harddisk

fdisk /dev/sda; # open up the first hd for creating a new partition
n; # new partition
p; # primary
Partition number (2,3, default 2); # just hit enter here to go with the default;
# give new size of partition
+128G
w; # write changes to disk and exit

The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

# Device or resource busy -> note: you might need to reboot now to make the changes effective (inform kernel)

reboot; # reboot system
lsblk; # checkout what is there

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 47.7G 0 disk
├─sda1 8:1 0 23.9G 0 part /
└─sda2 8:2 0 23.9G 0 part <- this is new
sr0 11:0 1 1024M 0 rom

mkfs.ext4 -L "name-of-partition" /dev/sda2; # format the partition with ext3
e2label /dev/sda2 "DATA"; # label the partition DATA

mkdir /mnt/sda2; # create mountpoint

vim /etc/fstab; # open fstab config file for automounting the partition

# at the end of the file add the following line
/dev/sda2 /mnt/sda2 ext4 relatime,errors=remount-ro 0 1

# mount options explained:

# relatime
## A filesystem mount with this option causes the access time to be updated if they are (before the update has occurred) earlier than the modification time.
## This significantly cuts down the writes caused by atime updates.
## However not many people use this option because they are simply not aware of it.
## relatime is a good compromise between atime (most expensive) and noatime (least expensive).

# errors=remount-ro
## will mount the filesystem in read-only mode in case there are any problems with it. This prevents you from potentially losing data using a bad filesystem.
## If this happened to one of your partitions, you should probably boot from a livecd or floppy (if it's not on your root partition, you can boot on recovery mode) and then run fsck on the affected disk.

:wq; # save and quit vim

reboot; # reboot again

mount; # checkout mount points

mount|grep sda2; # checkout mount points of sda2
/dev/sda2 on /mnt/sda2 type ext3 (rw,relatime,errors=remount-ro,data=ordered)

# sda2 was correctly and on-boot mounted to /mnt/sda2

cd /mnt/sda2; # go there
touch 1 2 3; # make some changes;
rm 1 2 3; # works


have PHUN!

Links:

https://dwaves.de/2017/05/19/linux-server-and-partitioning-stability-and-security/

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin