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

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

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

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

[root@guohuilinuxas31 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@guohuilinuxas31 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@guohuilinuxas31 root]# id

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

[root@guohuilinuxas31 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@guohuilinuxas31 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@guohuilinuxas31 etc]# mount /dev/sda4 /vmware1

[root@guohuilinuxas31 etc]# du -csh /vmware1

20K     /vmware1

20K     total

[root@guohuilinuxas31 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@guohuilinuxas31 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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值