Working with Partitions

Each hard disk that you use in a Linux system will have a number of partitions on it (except in the rather rare cases when we write to raw disk devices). To list (-l) the disks and partitions that the system can see, type the following:

Disk /dev/sda: 40.0 GB, 40007761920 bytes

16 heads, 63 sectors/track, 77520 cylinders

Units = cylinders

of 1008 *

512 = 516096

bytes

Device Boot

Start

End

Blocks

Id

System

/dev/sdal *

1

12484

6291904+

83

Linux

/dev/sda2

12485

16646

2097648

82

Linux swap

/dev/sda3

16647

47854

15728832

83

Linux

/dev/sda4

47855

77520

14951664

83

Linux

This shows you the partitions that the system can see, whether or not they are mounted. It provides, in more digestible form, the information that can also be seen in the virtual file /proc/partitions:

This shows you the partitions that the system can see, whether or not they are mounted. It provides, in more digestible form, the information that can also be seen in the virtual file /proc/partitions:

[email protected]:/tmp # cat /proc/partitions major minor #blocks name

3 0 39070080 sda

3 1 6291904 sdal

3 2 2097648 sda2

3 3 15728832 sda3

3 4 14951664 sda4

The fdisk -l command (along with the outputs of mount and df -h) is useful for understanding what you've got, how much of it, and where:

[email protected]:~> mount

/dev/sdal on / type reiserfs (rw,acl,user_xattr)

proc on /proc type proc (rw)

tmpfs on /dev/shm type tmpfs (rw)

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

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

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

Filesystem

Size

Used

Avail

Use%

Mounted on

/dev/sda1

6.1G

5.5G

599M

91%

/

tmpfs

253M

8.0K

253M

1%

/dev/shm

/dev/sda3

15G

12G

2.8G

81%

/home

/dev/sda4

15G

12G

1.5G

89%

/space

Before doing anything with your partitions, you should at least run the three commands we just mentioned. Together they should reassure you that you know what partitions exist and what they contain and make it less likely that you will accidentally do something destructive.

When you work with partitions, most of your time is spent when you install the system, and at that time you will be using YaST's partitioning capabilities. At other times, if you simply want to create partitions on a new disk, you are likely to do this using fdisk, but you can use YaST's partitioning module at any time from the YaST menu or by typing (as root) the following:

yast2 disk

You will first see a warning (see Figure 14-4).

FIGURE 14-4

YaST's partitioning warning

FIGURE 14-4

YaST's partitioning warning

Take that warning seriously, regardless of the tool that you are using to do partitioning — one false move and you can destroy your system.

If you continue, you will see the screen shown in Figure 14-5.

j r - - r You may notice that YaST reports the starting and ending cylinders differently from h . „■ t . - . ..-r . fdisk because fdisk starts counting from 0, whereas YaST counts from 1.

YaST uses the functionality of parted rather than fdisk to do its job. Thus, in addition to creating and destroying partitions, it is also capable of resizing them. It can also call ntfsresize to resize NTFS partitions.

I Partitions and the principles of partitioning are discussed in further detail in Chapters

Was this article helpful?

0 0

Post a comment