linux硬盤擴充技術查考指南

<p>&#160;</p> <p><b></b></p> <p><b>1、查看硬盤狀態命令,</b><b> fdisk -l</b></p> <p>顯示以下信息:</p> <p>Disk /dev/sda: 107.4 GB, 107374182400 bytes</p> <p>255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors</p> <p>Units = sectors of 1 * 512 = 512 bytes</p> <p>Sector size (logical/physical): 512 bytes / 512 bytes</p> <p>I/O size (minimum/optimal): 512 bytes / 512 bytes</p> <p>Disk identifier: 0x0006b898</p> <p>Device Boot Start End Blocks Id System</p> <p>/dev/sda1 * 2048 499711 248832 83 Linux</p> <p>/dev/sda2 501758 209713151 104605697 5 Extended</p> <p>/dev/sda5 501760 209713151 104605696 8e Linux LVM</p> <p>#上面代表這塊硬盤名字叫 /dev/sda,目前已經在用了,分區已經分好了。</p> <p>Disk /dev/sdc: 1073.7 GB, 1073741824000 bytes</p> <p>255 heads, 63 sectors/track, 130541 cylinders, total 2097152000 sectors</p> <p>Units = sectors of 1 * 512 = 512 bytes</p> <p>Sector size (logical/physical): 512 bytes / 512 bytes</p> <p>I/O size (minimum/optimal): 512 bytes / 512 bytes</p> <p>Disk identifier: 0x00000000</p> <p>Disk /dev/sdc doesn't contain a valid partition table</p> <p>#上面代表這塊硬盤名字叫 /dev/sdc,目前還不能使用,文件系統沒有建好。</p> <p>Disk /dev/mapper/i--2--15703--VM-swap_1: 1606 MB, 1606418432 bytes</p> <p>255 heads, 63 sectors/track, 195 cylinders, total 3137536 sectors</p> <p>Units = sectors of 1 * 512 = 512 bytes</p> <p>Sector size (logical/physical): 512 bytes / 512 bytes</p> <p>I/O size (minimum/optimal): 512 bytes / 512 bytes</p> <p>Disk identifier: 0x00000000</p> <p>Disk /dev/mapper/i--2--15703--VM-swap_1 doesn't contain a valid partition table</p> <p>#上面代表這塊硬盤名字叫 /dev/mapper/i--2--15703--VM-swap_1,這是交換的分區信息,暫時不用管。</p> <p><b></b></p> <p><b></b></p> <p><b></b></p> <p><b>2、在不能使用的硬盤上面新建文件系統。</b><b></b></p> <p><b>step1: fdisk /dev/sdc #</b><b>查看這塊硬盤的信息</b><b></b></p> <p>這時會進入對話窗口</p> <p>Disk /dev/sdc: 1073.7 GB, 1073741824000 bytes</p> <p>255 heads, 63 sectors/track, 130541 cylinders, total 2097152000 sectors</p> <p>Units = sectors of 1 * 512 = 512 bytes</p> <p>Sector size (logical/physical): 512 bytes / 512 bytes</p> <p>I/O size (minimum/optimal): 512 bytes / 512 bytes</p> <p>Disk identifier: 0xaf9232a2</p> <p>Device Boot Start End Blocks Id System</p> <p><b>step2: </b><b>新建分區</b><b> </b><b>命令</b><b> n</b></p> <p>Command (m for help): n</p> <p>Partition type:</p> <p>p primary (0 primary, 0 extended, 4 free)</p> <p>e extended</p> <p>Select (default p): p #新建主分區</p> <p>Partition number (1-4, default 1): 1 #1號主分區</p> <p>First sector (2048-2097151999, default 2048):</p> <p>Using default value 2048</p> <p>Last sector, +sectors or +size{K,M,G} (2048-2097151999, default 2097151999):</p> <p>Using default value 2097151999 #將全部空間都交給主分區</p> <p>最後 w 命令保存退出。</p> <p><b>step3: </b><b>格式化分區爲文件系統</b><b></b></p> <p>mkfs.ext3 /dev/sdc1</p> <p>mke2fs 1.42 (29-Nov-2011)</p> <p>Filesystem label=</p> <p>OS type: Linux</p> <p>Block size=4096 (log=2)</p> <p>Fragment size=4096 (log=2)</p> <p>Stride=0 blocks, Stripe width=0 blocks</p> <p>65536000 inodes, 262143744 blocks</p> <p>13107187 blocks (5.00%) reserved for the super user</p> <p>First data block=0</p> <p>Maximum filesystem blocks=4294967296</p> <p>8000 block groups</p> <p>32768 blocks per group, 32768 fragments per group</p> <p>8192 inodes per group</p> <p>Superblock backups stored on blocks:</p> <p>32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,</p> <p>4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,</p> <p>102400000, 214990848</p> <p>Allocating group tables: done</p> <p>Writing inode tables: done</p> <p>Creating journal (32768 blocks): done</p> <p>Writing superblocks and filesystem accounting information: done</p> <p><b>step4: </b><b>掛載新的分區</b><b></b></p> <p>在你想要掛載的位置以外,執行命令,好比我想掛載在 mnt/mydisk2目錄下面</p> <p>這時候你必須在這個目錄以外執行</p> <p>Mount dev/sdc1 mnt/mydisk2</p> <p><b>step5: </b><b>查看掛載空間大小</b><b></b></p> <p>root@i-2-15703-VM:/# df -h</p> <p>Filesystem Size Used Avail Use% Mounted on</p> <p>/dev/mapper/i--2--15703--VM-root 99G 72G 23G 77% /</p> <p>udev 3.9G 4.0K 3.9G 1% /dev</p> <p>tmpfs 1.6G 276K 1.6G 1% /run</p> <p>none 5.0M 0 5.0M 0% /run/lock</p> <p>none 3.9G 0 3.9G 0% /run/shm</p> <p>/dev/sda1 228M 25M 192M 12% /boot</p> <p>/dev/sdc1 985G 200M 935G 1% /mnt/mydisk2</p> <p><b></b></p> <p><b></b></p> <p><b>ps</b><b>:配置開機自動掛載</b><b></b></p> <p><b>由於</b><b>mount</b><b>掛載在重啓服務器後會失效,因此須要將分區信息寫到</b><b>/etc/fstab</b><b>文件中讓它永久掛載:</b><b></b></p> <p><b>e2label /dev/hda6 </b><b>先查看須要掛載硬盤分區的</b><b>lable</b></p> <p><b>/home</b></p> <p><b>e2label /dev/hda6 home1 </b><b>由於系統中已經有個</b><b>/home</b><b>的</b><b>label</b><b>了,因此這裏要從新把</b><b>/dev/hda6</b><b>的</b><b>label</b><b>設置爲</b><b>home1</b></p> <p><b>vi /etc/fstab</b></p> <p><b>加入:</b><b></b></p> <p><b>LABEL=home1 /data1 ext3 defaults 1 2</b></p> <p><b>注意紅色</b><b>home1</b><b>左邊沒有</b><b>/</b><b>。</b><b></b></p> <p><b>查看</b><b>cat /etc/fstab</b></p> <p><b>LABEL=/ / ext3 defaults 1 1</b></p> <p><b>LABEL=/data /data ext3 defaults 1 2</b></p> <p><b>LABEL=home1 /data1 ext3 defaults 1 2</b></p> <p><b>LABEL=/boot /boot ext3 defaults 1 2</b></p> <p><b>tmpfs /dev/shm tmpfs defaults 0 0</b></p> <p><b>devpts /dev/pts devpts gid=5,mode=620 0 0</b></p> <p><b>sysfs /sys sysfs defaults 0 0</b></p> <p><b>proc /proc proc defaults 0 0</b></p> <p><b>LABEL=SWAP-hda3 swap swap defaults 0 0</b></p> <p><b>在修改</b><b>/etc/fstab</b><b>文件後,運行</b><b>mount -a</b><b>命令驗證一下配置是否正確,不然錯誤配置</b><b>fstab</b><b>文件致使系統沒法正常啓動。若是系統沒法正常啓動,則輸入</b><b>root</b><b>密碼進入修復模式,關鍵的一步是從新</b><b>mount /</b><b>(</b><b>mount -n -o remount,rw /</b><b>)。若是沒有此步操做,則文件系統處於只讀狀態,致使不能修改配置文件並保存,修復存在的問題。</b></p>node

相關文章
相關標籤/搜索