Adding a new disk to CentOS
For the purpose of this article, assume that /dev/sdb
is the new disk that is to be installed.
1 2 3 4 |
# Display available disks lsblk |
Create linux partition on a disk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# Become root sudo su - # /dev/sdb is the new disk that needs to be installed fdisk /dev/sdb # Change display/entry units to sectors # In fdisk interface enter c and then u # View current partitions on disk Enter p # Create new partition Enter n # No of partitions that you want to create Enter 1,2,3 or 4 # e = extended, p = primary partition Enter e or p # Actually Write / perform the actions to disk Enter w |
1 2 3 4 |
# Display the new partition (/dev/sdb1) lsblk |
Create files system on the new partiton
1 2 3 4 |
# Create filesystem /sbin/mkfs.ext4 -L /backup /dev/sdb1 |
Mount the filesystem
1 2 3 4 5 6 7 8 9 10 |
# Create a mount point mkdir /backup # Mount the new filesystem at /backup mount /dev/sdb1 /backup # Display a list of all currently mounted filesystems mount |
Now add entry to /etc/fstab
so that the new filesystem is automatically mounted at boot time e.g.
1 2 3 |
UUID="D19AF762-BC4B-3791-87D2-4CDC74831E0B" /data xfs defaults 0 0 |
To get UUID for a partition, you can use the command:
For CentOS:
1 2 3 |
blkid |
For a MacOS:
1 2 3 |
diskutil info <partiton> e.g. /dev/disk1s1 |
A note on using noatime
and nodiratime
:
Since Linux 2.6.30 (released in 2009) the default behaviour for filesystem timestamps is as follows (taken from man
page for mount
):
Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time. (Similar to noatime, but it doesn't break mutt or other applications that need to know if a file has been read since the last time it was modified).
Since Linux 2.6.30, the kernel defaults to the behavior provided by this option (unless noatime was specified), and the strictatime option is required to obtain traditional semantics. In addition, since Linux 2.6.30, the file's last access time is always updated if it is more than 1 day old.
This new behaviour for atime
is called relatime
. So there may be little or no apparent performance gain by using noatime
explicitly and it’s true for ext
and xfs
filesystems.
Recent Posts
- Enable http/2 in Apache 16th Jan 2021
- MySQL Shell 8.x 16th Jan 2021
- vi/vim tricks 30th Dec 2020
- SELinux on CentOS 29th Dec 2020
- ssh-copy-id (password less ssh login) 26th Dec 2020
- MySQL auto_increment capacity calculation 26th Dec 2020
- Using UUID as a Primary Key 24th Dec 2020
- Keycloak and InnoDB Cluster 29th Nov 2020
- How to create Column in MySQL only if one does not exist? 19th Mar 2019
- Inject empty transactions in MySQL 5.6 GTID based Replication 25th Dec 2018
- Adding a new disk to CentOS 26th Aug 2018
- mysqldump extended inserts 26th Jun 2018
- CentOS Logical Volume Manager (LVM) 26th Oct 2017
- How to prepare SD Card for Raspberry Pi on a MAC 26th Jun 2017
- Convert .dmg file on a MAC to .iso 26th Apr 2017
Categories
- CentOS (4)
- CentOS 8 (2)
- InnoDB cluster (1)
- mysql (7)
- Raspberry Pi (1)
- ssh (1)
- Technical (3)
Tag cloud
Archives
- January 2021 (2)
- December 2020 (5)
- November 2020 (1)
- March 2019 (1)
- December 2018 (1)
- August 2018 (1)
- June 2018 (1)
- October 2017 (1)
- June 2017 (1)
- April 2017 (1)
- February 2016 (1)