感谢支持
我们一直在努力

Linux 空闲空间的格式化与加载

本人有块SCSI硬盘,安装Linux AS4 时没有分区,安装好了系统后想把这块空闲分区使用上,以下是详细的操作步骤


一、使用linux as4的硬件查看工具查看未使用的硬盘空间。



二、使用fdisk对空闲分区分区。


[root@www.linuxidc.com root]# fdisk /dev/sda


The number of cylinders for this disk is set to 5221.


There is nothing wrong with that, but this is larger than 1024,


and could in certain setups cause problems with:


1) software that runs at boot time (e.g., old versions of LILO)


2) booting and partitioning software from other OSs


   (e.g., DOS FDISK, OS/2 FDISK)


Command (m for help): p


Disk /dev/sda: 42.9 GB, 42949672960 bytes


255 heads, 63 sectors/track, 5221 cylinders


Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot    Start       End    Blocks   Id  System


/dev/sda1   *         1        13    104391   83  Linux


/dev/sda2            14      2356  18820147+  83  Linux


/dev/sda3          2357      2610   2040255   82  Linux swap


Command (m for help): n


Command action


   e   extended


   p   primary partition (1-4)


e


Selected partition 4


First cylinder (2611-5221, default 2611):


[root@www.linuxidc.com root]# fdisk /dev/sda


The number of cylinders for this disk is set to 5221.


There is nothing wrong with that, but this is larger than 1024,


and could in certain setups cause problems with:


1) software that runs at boot time (e.g., old versions of LILO)


2) booting and partitioning software from other OSs


   (e.g., DOS FDISK, OS/2 FDISK)


Command (m for help): n


Command action


   e   extended


   p   primary partition (1-4)


p


Selected partition 4


First cylinder (2611-5221, default 2611): 2611


Last cylinder or +size or +sizeM or +sizeK (2611-5221, default 5221): 5221


Command (m for help): p


Disk /dev/sda: 42.9 GB, 42949672960 bytes


255 heads, 63 sectors/track, 5221 cylinders


Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot    Start       End    Blocks   Id  System


/dev/sda1   *         1        13    104391   83  Linux


/dev/sda2            14      2356  18820147+  83  Linux


/dev/sda3          2357      2610   2040255   82  Linux swap


/dev/sda4          2611      5221  20972857+  83  Linux


Command (m for help): w


The partition table has been altered!


Calling ioctl() to re-read partition table.


WARNING: Re-reading the partition table failed with error 16: Device or resource busy.


The kernel still uses the old table.


The new table will be used at the next reboot.


Syncing disks.

三、重启系统


#reboot


再次查看空间,可以看到free的空间变成了linux的文件格式。



设备号 sda4,没有文件系统。


四、格式化新分配的空间。


[root@www.linuxidc.com root]# id


uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)


[root@www.linuxidc.com root]# mkfs -t ext3 /dev/sda4


mke2fs 1.32 (09-Nov-2002)


warning: 334 blocks unused.


Filesystem label=


OS type: Linux


Block size=4096 (log=2)


Fragment size=4096 (log=2)


2626560 inodes, 5242880 blocks


262160 blocks (5.00%) reserved for the super user


First data block=0


160 block groups


32768 blocks per group, 32768 fragments per group


16416 inodes per group


Superblock backups stored on blocks:


        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,


        4096000


Writing inode tables: done                           


Creating journal (8192 blocks): done


Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 20 mounts or


180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@www.linuxidc.com root]# fdisk -l


Disk /dev/sda: 42.9 GB, 42949672960 bytes


255 heads, 63 sectors/track, 5221 cylinders


Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot    Start       End    Blocks   Id  System


/dev/sda1   *         1        13    104391   83  Linux


/dev/sda2            14      2356  18820147+  83  Linux


/dev/sda3          2357      2610   2040255   82  Linux swap


/dev/sda4          2611      5221  20972857+  83  Linux


可以看到空闲空间为sda4。



五、加载文件系统


[root@www.linuxidc.com etc]# mount /dev/sda4 /vmware1


[root@www.linuxidc.com etc]# du -csh /vmware1


20K     /vmware1


20K     total


[root@www.linuxidc.com etc]# mount


/dev/sda2 on / type ext3 (rw)


none on /proc type proc (rw)


none on /dev/pts type devpts (rw,gid=5,mode=620)


usbdevfs on /proc/bus/usb type usbdevfs (rw)


/dev/sda1 on /boot type ext3 (rw)


none on /dev/shm type tmpfs (rw)


/dev/sda4 on /vmware1 type ext3 (rw)


[root@www.linuxidc.com etc]# df -k


Filesystem           1K-blocks      Used Available Use% Mounted on


/dev/sda2             18524524   9287492   8296028  53% /


/dev/sda1               101089     15126     80744  16% /boot


none                   1293016         0   1293016   0% /dev/shm


/dev/sda4             20641788     32828  19560320   1% /vmware1


六、自动加载文件系统


[Oracle@guohuilinuxas31 etc]$ cat fstab


LABEL=/                 /                       ext3    defaults        1 1


LABEL=/boot             /boot                   ext3    defaults        1 2


/dev/sda4               /vmware1                ext3    defaults        1 3


none                    /dev/pts                devpts  gid=5,mode=620  0 0


none                    /proc                   proc    defaults        0 0


none                    /dev/shm                tmpfs   defaults        0 0


/dev/sda3               swap                    swap    defaults        0 0


/dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0


/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0

赞(0) 打赏
转载请注明出处:服务器评测 » Linux 空闲空间的格式化与加载
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏