最近公司新購了一臺(tái)戴爾R720的服務(wù)器,昨天u盤安裝ubuntu系統(tǒng)后,首先要做的就是把另外兩個(gè)raid設(shè)備掛載到服務(wù)器。現(xiàn)在在虛擬機(jī)中用root用戶操作,掛載的具體步驟如下。
1、測(cè)試硬盤是否已連接
首先先查看硬盤信息。sda是虛擬的第一塊硬盤,sdb是第二塊硬盤,以此類推。
root@zhang:~# ls -l /dev/sd* brw-rw---- 1 root disk 8, 0 2013-08-13 08:33 /dev/sda brw-rw---- 1 root disk 8, 1 2013-08-13 08:33 /dev/sda1 brw-rw---- 1 root disk 8, 2 2013-08-13 08:33 /dev/sda2 brw-rw---- 1 root disk 8, 5 2013-08-13 08:33 /dev/sda5 brw-rw---- 1 root disk 8, 16 2013-08-13 08:33 /dev/sdb #此命令測(cè)試linux系統(tǒng)是否能找到掛載的未分區(qū)硬盤 root@zhang:~# hdparm -I /dev/sdb #這個(gè)是未掛載之前的硬盤信息 root@zhang:~# fdisk -l Disk /dev/sda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000cf88c Device Boot Start End Blocks Id System /dev/sda1 * 1 994 7977984 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 994 1045 407553 5 Extended /dev/sda5 994 1045 407552 82 Linux swap / Solaris Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn\'t contain a valid partition table
2、創(chuàng)建硬盤分區(qū)
root@zhang:~# 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 0xcbd0c60e. 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\'). # 輸入m,查看幫助信息 Command (m for help): m Command action a toggle a bootable flag 將分區(qū)設(shè)置為啟動(dòng)區(qū) b edit bsd disklabel 編輯bsd的disklabel c toggle the dos compatibility flag 設(shè)置該分區(qū)為dos分區(qū) d delete a partition 刪除分區(qū) l list known partition types 列出已知的分區(qū)類型 m print this menu 打印幫助列表 n add a new partition 創(chuàng)建新分區(qū) o create a new empty DOS partition table p print the partition table查看分區(qū)信息 q quit without saving changes 退出不保存 s create a new empty Sun disklabel t change a partition\'s system id改變分區(qū)類型 u change display/entry units v verify the partition table w write table to disk and exit 保存退出 x extra functionality (experts only) #查看sdb這塊硬盤的分區(qū) Command (m for help): p Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xcbd0c60e Device Boot Start End Blocks Id System #創(chuàng)建sdb這塊硬盤的分區(qū) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1044, default 1): Using default value 1 Last cylinder, cylinders or size{K,M,G} (1-1044, default 1044): Using default value 1044 #查看創(chuàng)建sdb硬盤的分區(qū) Command (m for help): p Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xcbd0c60e Device Boot Start End Blocks Id System /dev/sdb1 1 1044 8385898 83 Linux #保存退出,分區(qū)創(chuàng)建結(jié)束。 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. #再用fdisk -l查看硬盤信息就可以看到sdb1新分區(qū)了 root@zhang:~# fdisk -l Disk /dev/sda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000cf88c Device Boot Start End Blocks Id System /dev/sda1 * 1 994 7977984 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 994 1045 407553 5 Extended /dev/sda5 994 1045 407552 82 Linux swap / Solaris Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xcbd0c60e Device Boot Start End Blocks Id System /dev/sdb1 1 1044 8385898 83 Linux
3、格式化硬盤
root@zhang:~# mkfs -t ext4 /dev/sdb1 mke2fs 1.41.11 (14-Mar-2010) 文件系統(tǒng)標(biāo)簽= 操作系統(tǒng):Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 524288 inodes, 2096474 blocks 104823 blocks (5.00%) reserved for the super user 第一個(gè)數(shù)據(jù)塊=0 Maximum filesystem blocks=2147483648 64 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 正在寫入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
4、給新建的sdb1設(shè)置卷標(biāo)命名,創(chuàng)建掛載點(diǎn)。
root@zhang:~# e2label /dev/sdb1 /data root@zhang:~# mkdir /data
5、設(shè)置開機(jī)自動(dòng)掛載
在上面一個(gè)步驟中,我已經(jīng)把sdb1這個(gè)分區(qū)重新命名,當(dāng)然也可以在設(shè)置自動(dòng)掛載的時(shí)候用UUID。
root@zhang:~# ls -l /dev/disk/ total 0 drwxr-xr-x 2 root root 280 2013-08-13 08:47 by-id drwxr-xr-x 2 root root 60 2013-08-13 08:52 by-label drwxr-xr-x 2 root root 180 2013-08-13 08:47 by-path drwxr-xr-x 2 root root 100 2013-08-13 08:51 by-uuid #查看設(shè)置的卷標(biāo)名稱,這里有上一步中命名的分區(qū)/data root@zhang:~# ls -l /dev/disk/by-label/ total 0 lrwxrwxrwx 1 root root 10 2013-08-13 08:52 \\x2fdata -> ../../sdb1 #查看各個(gè)分區(qū)的uuid號(hào) root@zhang:~# ls -l /dev/disk/by-uuid/ total 0 lrwxrwxrwx 1 root root 10 2013-08-13 08:33 b6dbd10c-7995-4b3d-abf0-2da1622298da -> ../../sda1 lrwxrwxrwx 1 root root 10 2013-08-13 08:33 d0d8b0bf-dc99-4d38-937d-f34d88072ce9 -> ../../sda5 lrwxrwxrwx 1 root root 10 2013-08-13 08:52 f90991b0-1082-45d8-b00d-87dceb81115e -> ../../sdb1 #設(shè)置開機(jī)自動(dòng)掛載分區(qū)sdb1 root@zhang:~# vi /etc/fstab # /etc/fstab: static file system information. # # Use \'blkid -o value -s UUID\' to print the universally unique identifier # for a device; this may be used with UUID= as a more robust way to name # devices that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda1 during installation UUID=b6dbd10c-7995-4b3d-abf0-2da1622298da / ext4 errors=remount-ro 0 1 # swap was on /dev/sda5 during installation UUID=d0d8b0bf-dc99-4d38-937d-f34d88072ce9 none swap sw 0 0 LABEL=/data /data ext4 defaults 0 2 #或者用UUID,效果都是一樣的。 #UUID=f90991b0-1082-45d8-b00d-87dceb81115e /data ext4 defaults 0 2
6、重新啟動(dòng)查看掛載結(jié)果
root@zhang:~# df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda1 7.5G 1.5G 5.7G 20% / none 243M 216K 243M 1% /dev none 247M 0 247M 0% /dev/shm none 247M 56K 247M 1% /var/run none 247M 0 247M 0% /var/lock none 247M 0 247M 0% /lib/init/rw /dev/sdb1 7.9G 146M 7.4G 2% /data #掛載成功
西部數(shù)碼(west.cn)是經(jīng)工信部審批,持有ISP、云牌照、IDC、CDN全業(yè)務(wù)資質(zhì)的正規(guī)老牌云服務(wù)商,自成立至今20余年專注于域名注冊(cè)、虛擬主機(jī)、云服務(wù)器、企業(yè)郵箱、企業(yè)建站等互聯(lián)網(wǎng)基礎(chǔ)服務(wù)!
公司自研的云計(jì)算平臺(tái),以便捷高效、超高性價(jià)比、超預(yù)期售后等優(yōu)勢(shì)占領(lǐng)市場(chǎng),穩(wěn)居中國接入服務(wù)商排名前三,為中國超過50萬網(wǎng)站提供了高速、穩(wěn)定的托管服務(wù)!先后獲評(píng)中國高新技術(shù)企業(yè)、中國優(yōu)秀云計(jì)算服務(wù)商、全國十佳IDC企業(yè)、中國最受歡迎的云服務(wù)商等稱號(hào)!
目前,西部數(shù)碼高性能云服務(wù)器正在進(jìn)行特價(jià)促銷,最低僅需48元!
https://www.west.cn/cloudhost/