Is this page when I talk about drives I mean:
Floppies, CD/DVD, USB sticks and memory-cards are considered removable media.
In computing, a file system or filesystem (often abbreviated to fs) controls how data is stored and retrieved. Without a file system, data placed in a storage medium would be one large body of data with no way to tell where one piece of data stops and the next begins. By separating the data into pieces and giving each piece a name, the data is easily isolated and identified. Taking its name from the way paper-based data management system is named, each group of data is called a "file." The structure and logic rules used to manage the groups of data and their names is called a "file system."
There are many different kinds of file systems. Each one has different structure and logic, properties of speed, flexibility, security, size and more. Some file systems have been designed to be used for specific applications. For example, the ISO 9660 file system is designed specifically for optical discs.
File systems can be used on numerous different types of storage devices that use different kinds of media. As of 2019, hard disk drives have been key storage devices and are projected to remain so for the foreseeable future. Other kinds of media that are used include SSDs, magnetic tapes, and optical discs. In some cases, such as with tmpfs, the computer's main memory (random-access memory, RAM) is used to create a temporary file system for short-term use.
All partitions are attached to the system via a mount point. The mount point defines the place of a particular data set in the file system. Usually, all partitions are connected through the root partition. On this partition, which is indicated with the slash (/), directories are created. These empty directories will be the starting point of the partitions that are attached to them. An example: given a partition that holds the following directories:
# findmnt --fstab --evaluate TARGET SOURCE FSTYPE OPTIONS / /dev/sdb3 xfs defaults /boot /dev/sdb2 xfs defaults /boot/efi /dev/sdb1 vfat umask=0077,shortname=winnt /home /dev/sda5 xfs defaults /srv /dev/sda1 xfs defaults /tmp /dev/sda2 xfs defaults /var /dev/sda3 xfs defaults none /dev/sda4 swap defaults
The system uses /etc/fstab to keep record of the mountpoints.
# # /etc/fstab # Created by anaconda on Fri Aug 16 23:23:56 2024 # # 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. # # After editing this file, run 'systemctl daemon-reload' to update systemd # units generated from this file. # UUID=48008d29-c0c0-45da-a102-10cd8d5c9b48 / xfs defaults 0 0 UUID=ee42c921-a6f5-4391-829f-c2fc1f8f6bf6 /boot xfs defaults 0 0 UUID=F757-9776 /boot/efi vfat umask=0077,shortname=winnt 0 2 UUID=7c6c47bf-47d0-4008-b067-da6724790c40 /home xfs defaults 0 0 UUID=f24375a2-6a3f-4bc7-b12f-2b5df1507560 /srv xfs defaults 0 0 UUID=ce286dd9-fee5-4fce-8660-ff8598531d65 /tmp xfs defaults 0 0 UUID=d0160878-8b9f-4e0e-a86b-f489e7b0d99e /var xfs defaults 0 0 UUID=da0e050c-8c35-46dd-abbb-b51e5289c389 none swap defaults 0 0
Rocky uses UUID's. It replaced /dev/sda types. To know wich device has what UUID type:
# blkid -s UUID /dev/sdb2: UUID="ee42c921-a6f5-4391-829f-c2fc1f8f6bf6" /dev/sdb3: UUID="48008d29-c0c0-45da-a102-10cd8d5c9b48" /dev/sdb1: UUID="F757-9776" /dev/sda4: UUID="da0e050c-8c35-46dd-abbb-b51e5289c389" /dev/sda2: UUID="ce286dd9-fee5-4fce-8660-ff8598531d65" /dev/sda5: UUID="7c6c47bf-47d0-4008-b067-da6724790c40" /dev/sda3: UUID="d0160878-8b9f-4e0e-a86b-f489e7b0d99e" /dev/sda1: UUID="f24375a2-6a3f-4bc7-b12f-2b5df1507560"
When we want to know how much space is used enter:
# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 3.7G 0 3.7G 0% /dev/shm tmpfs 1.5G 8.9M 1.5G 1% /run /dev/sdb3 220G 4.7G 216G 3% / /dev/sdb2 2.0G 394M 1.6G 20% /boot /dev/sda2 16G 147M 16G 1% /tmp /dev/sda1 48G 499M 48G 2% /srv /dev/sdb1 1022M 7.1M 1015M 1% /boot/efi /dev/sda5 3.6T 41G 3.6T 2% /home /dev/sda3 16G 1.8G 15G 11% /var tmpfs 755M 4.0K 755M 1% /run/user/0
If you need a quick view of your drives and usb sticks use:
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 3.6T 0 disk ├─sda1 8:1 0 48G 0 part /srv ├─sda2 8:2 0 16G 0 part /tmp ├─sda3 8:3 0 16G 0 part /var ├─sda4 8:4 0 8G 0 part [SWAP] └─sda5 8:5 0 3.6T 0 part /home sdb 8:16 0 223.6G 0 disk ├─sdb1 8:17 0 1G 0 part /boot/efi ├─sdb2 8:18 0 2G 0 part /boot └─sdb3 8:19 0 220G 0 part /
Best practice is to buy new drives for a server - that is data server use - and not reusing old server drives which have already run for a long time. You can reuse desktop drives when they haven't run continual.
A year has 8766 hour.
When we choose to use a SSD we need at least one HDD beside it to protect de SSD from over writing (It has limited write times). Reading from it is no problem.
Directory | HDD | SSD |
---|---|---|
swap | Yes | No |
/ | Yes | Yes |
/boot/ | Yes | Yes |
/tmp/ | Yes | No |
/home/ | Yes | No |
/srv/ | Yes | No |
/var/ | Yes | No |
other | Yes | Yes |
Amount of RAM in the system | Recommended swap space | Recommended swap space if allowing for hibernation |
---|---|---|
≤ 2GB | 2 times the amount of RAM | 3 times the amount of RAM |
2GB - 8GB | Equal to the amount of RAM | 2 times the amount of RAM |
8GB - 64GB | At least 4 GB | 1.5 times the amount of RAM |
> 64GB | At least 4 GB | Hibernation not recommended |
A server doesn't hibernate. HDD should run continu.
My system uses with 2 GB RAM:
# free total used free shared buff/cache available Mem: 1816504 651792 282988 72448 881724 922312 Swap: 4194300 68864 4125436
When you start your install you will be asked how to partition your drives. I use standard partioning so you are limited to the phisical size of the drives.
1 | /boot | 2048 MB |
2 | /boot/efi | 1024 MB |
3 | swap | See above |
4 | / | Rest |
HDD 1 | ||
---|---|---|
1 | /boot | 2048 MB |
2 | /boot/efi | 1024 MB |
3 | swap | See above |
4 | / | Rest |
HDD 2 | ||
1 | /home | All |
This is not recommended for file and webservers. For database servers it depands on how much the database is changed.
For systems that have little write activity like non-CMS webservers it might be OK. The SWAP partitoin is problaby the biggest problem if you need one.
For the SSD we need at least 40 GB and for the HDD we need ≥1 TB.
SSD | ||
---|---|---|
1 | /boot | 2048 MB |
2 | /boot/efi | 1024 MB |
3 | / | Rest |
HDD | ||
1 | swap | See above |
2 | /tmp | 16 GB |
3 | /var | 16 GB |
4 | /srv | 32 GB |
5 | /home | Rest |
For the SSD we need ±40 GB and for HDD1 we need ≥80 GB and for HDD2 as much as you need.
SSD | ||
---|---|---|
1 | /boot | 2048 MB |
2 | /boot/efi | 1024 MB |
3 | / | Rest |
HDD 1 | ||
1 | swap | See above |
2 | /tmp | 24 GB |
3 | /var | 24 GB |
4 | /srv | Rest |
HDD 2 | ||
5 | /home | All |
We can consider to store the html-code on the SSD. Make a mountpoint on the SSD for /srv/www. Reserve at least 25 GB for it.
The home dir is used for all users data. If you want to store videos you might consider to use a 4 TB disk.
In de srv dir we store all data for webpages and databases. A 25 GB partition wil be fine.
When a disk gets to small or begins to fail you need to replace de disk.
Before we start we need to know which drive has the home or srv partition. Replacing the bootdisk is tricky.
The command # blkid -s UUID show all active devices and the UUID. Note which are show.
Switch of the server and add the new drive on a free SATA port.
Start the server and check with blkid which device is new. Thats our new disk.
First we list the drives.
# parted -l Model: ATA WDC WD40EFAX-68J (scsi) Schijf /dev/sda: 4001GB Sectorgrootte (logisch/fysiek): 512B/4096B Partitietabel: gpt Schijfvlaggen: Nummer Begin Einde Grootte Bestandssysteem Naam Vlaggen 1 1049kB 4001GB 4001GB xfs home Model: ATA ST3500630AS (scsi) Schijf /dev/sdf: 500GB Sectorgrootte (logisch/fysiek): 512B/512B Partitietabel: msdos Schijfvlaggen: Nummer Begin Einde Grootte Type Bestandssysteem Vlaggen 1 1049kB 500GB 500GB primary xfs Model: ATA ST340012A (scsi) Schijf /dev/sdg: 40,0GB Sectorgrootte (logisch/fysiek): 512B/512B Partitietabel: msdos Schijfvlaggen: Nummer Begin Einde Grootte Type Bestandssysteem Vlaggen 1 1049kB 1075MB 1074MB primary xfs opstart 2 1075MB 5370MB 4295MB primary linux-swap(v1) 3 5370MB 40,0GB 34,7GB primary xfs
Whit this command we can also see what brand and type each disk is.
For partion up to 2 TB you can use msdos. For larger dan 2 TB you need gpt.
X is the new drive. Label is the MBR type.
# parted /dev/sdX (parted) mklabel gpt Warning: The existing disk label on /dev/sdX will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? y (parted) print free (parted) mkpart storage xfs 0% 100% (parted) print free (parted) quit Information: You may need to update /etc/fstab.
Next, format the new Linux partition with the xfs filesystem using mkfs.xfs.
# mkfs.xfs /dev/sdX1
After all partitions have been formatted you can use the new drive.
# blkid -s UUID /dev/sdX1: UUID="d98abe0a-f641-4331-a3dc-b89ebc60bfb5"
The new drive is formatted and ready to be mounted into the system. But the process of replacing another drive with this one isn't quite that simple. First, both drives must be mounted simultaneously to copy files from the old drive to the new one.
To do this, mount the new drive on a temporary mount point, copy the files, and then unmount both drives. Why? So you can mount the new drive at the same mount point where the old drive was mounted in order to preserve the path. In case there are applications with that path configured, it's just simpler this way.
# mount UUID="d98abe0a-f641-4331-a3dc-b89ebc60bfb5" /mnt # cp -Ra /home/* /mnt/
Use diff to verify the copy's success.
diff -rqy /home/ /mnt/
Now that the new drive contains all of the old files, remount it in place of the old drive. First, unmount both drives. sdb2 is the old drive with the home partion.
# umount /dev/sdX1 # umount /dev/sdb2
If the old drive will no longer be used as a swap device, disable it with the swapoff command.
# swapoff /dev/sdb1If you repeat the cat /proc/swaps command, it will no longer list this partition.
Go back to the /etc/fstab file; there are a few changes that you need to make. I advise making a backup of the file before editing it.
cp -a /etc/fstab /etc/fstab.backup
In the line for the /home mount point, replace the UUID with that of the new drive; replace the filesystem, ext4, with xfs; and add discard to the options. It should appear like this:
UUID=d98abe0a-f641-4331-a3dc-b89ebc60bfb5 /home xfs defaults,noatime,discard 0 2
After saving the fstab file, run mount to re-mount based on the changes.
# mount -av / : ignored /boot/efi : already mounted /home : successfully mounted
Finally, shut down the computer and remove the HDD that will no longer be used and connect the new HDD to the SATA port of the old one. Then power up and check that the system has booted correctly and that all drives are mounted as expected.
If you want to add the new drive you only need to add it to fstab.