Hard disk partition and mount of CentOS cloud server

  • 2020-05-15 03:21:32
  • OfStack

Cloud server environment: CentOS 6.2 64-bit

Client environment: Mac OSX

Remote connection: run Terminal and enter the command ssh username @ip

Operation steps of hard disk partitioning and mounting:

1. View the unmounted hard drive (name /dev/xvdb)


# fdisk -l 

Disk /dev/xvdb doesn't contain a valid partition table

2. Create a partition


# fdisk /dev/xvdb

...

Input n

Command (m for help):n

Input p

Command action

e extended

p primary partition (1-4)

p

Enter 1

Partition number (1-4): 1

enter

First cylinder (1-2610, default 1):

Using default value 1

enter

Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):

Using default value 2610

Input w

Command (m for help): w

The partition table has been altered!

3. Format the partition


# mkfs.ext3 /dev/xvdb1

4. Create mount directory


# mkdir /data

5. Mount the partition


# mount /dev/xvdb1 /data

6. Set the startup to mount automatically


vi /etc/fstab

Enter i in vi to enter INERT mode, move the cursor to the end of the file and press enter, copy/paste the following, then press Esc and enter :x save and exit

/dev/xvdb1 /data ext3 defaults 0 0

7. Verify that the mount was successful

Restart the server


# reboot

View hard disk partition


# df

/dev/xvdb1 20635700 176196 19411268 1% /data

Done! It feels good to remotely operate Linux via Terminal under Mac!


Related articles: