1须蜗、查看現(xiàn)有已掛載硬盤情況
[root@WSC-129-95 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 3.6G 15G 20% /
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 32G 1.2G 30G 4% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/sda4 1.8T 671M 1.7T 1% /data
/dev/sda3 20G 1006M 18G 6% /usr/local
2硅确、查看機器所有硬盤情況
通過和對比已掛載磁盤目溉,多出的一部分就是未掛載盤
[root@WSC-129-95 ~]# fdisk -l | grep -P "Disk /dev/[a-z]{0,3}:"
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdk: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sde: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdl: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdi: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdg: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdj: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdh: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
3、分區(qū)
fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x8b821ab0.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n #回車
Command action
e extended
p primary partition (1-4)
p #回車
Partition number (1-4): 1 #回車
First cylinder (1-13054, default 1): #回車
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054): #回車
Using default value 13054
Command (m for help): w #回車
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# 到這里分區(qū)工作已完成菱农,執(zhí)行fdisk -l可以看到多了一個分區(qū)
# 我是按照順序掛載磁盤缭付,所以第一個磁盤是sdb,對應(yīng)增加的分區(qū)就是sdb1
4循未、格式化
格式化可以按照指定格式進行格式化陷猫,相關(guān)命令輸入mkfs后按TAB鍵可以查看
這里我的系統(tǒng)是ext4文件系統(tǒng),如下所示
[root@WSC-129-95 ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122101760 inodes, 488378385 blocks
24418919 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2636120064
14905 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
5的妖、掛載
已經(jīng)完成分區(qū)和系統(tǒng)格式化后绣檬,只需將其掛載在操作系統(tǒng)上即可
[root@WSC-129-95 ~]# mount /dev/sdb1 /data1
# 掛載成功后,可以通過df -h查看是否掛載成功
[root@WSC-129-95 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 3.6G 15G 20% /
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 32G 1.2G 30G 4% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/sda4 1.8T 671M 1.7T 1% /data
/dev/sda3 20G 1007M 18G 6% /usr/local
/dev/sdb1 1.8T 77M 1.7T 1% /data1
6嫂粟、設(shè)置開機自動掛載
Linux中娇未,沒有寫入配置文件中的信息,重啟后都會失效星虹。
所以想要實現(xiàn)自動掛載零抬,需要配置文件信息。
vi /etc/fstab
# 增加一行內(nèi)容
/dev/sdb1 /data1 ext4 defaults 1 2
# 保存后退出搁凸,這里應(yīng)該是可以自動掛載了媚值。如需驗證,重啟下機器即可