Ubuntu server kettajao suuruse muutmine: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Mpopp (talk | contribs)
Mpopp (talk | contribs)
Line 19: Line 19:
/dev/sda6            1.9G  193M  1.6G  11% /home/first
/dev/sda6            1.9G  193M  1.6G  11% /home/first
/dev/sda7            938M  133M  758M  15% /home/second
/dev/sda7            938M  133M  758M  15% /home/second
</pre>
<pre>
root@popp:~# 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: 0x0000e9fe
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1        558    4480000  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2            558        1045    3905537    5  Extended
/dev/sda5            558        680      976896  82  Linux swap / Solaris
/dev/sda6            680        923    1950720  83  Linux
/dev/sda7            923        1045      975872  83  Linux
</pre>
</pre>



Revision as of 22:04, 7 December 2010

Sissejuhatus

Nõuded süsteemile

Antud lahendus on testitud Ubuntu Server 10.10 peal. Tegemist on kolme ext3 failisüsteemiga, millest ühte suurendame ning teist vähendame nii, et nendel olevad andmed säiliksid.

Ettevalmistus

Esmalt tuleb end logida juurkasutajaks

sudo -i

Uurime millised partitsioonid hetkel olemas on

root@popp:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             4.3G  2.2G  1.9G  55% /
none                  243M  232K  243M   1% /dev
none                  249M  224K  249M   1% /dev/shm
none                  249M   92K  249M   1% /var/run
none                  249M     0  249M   0% /var/lock
/dev/sda6             1.9G  193M  1.6G  11% /home/first
/dev/sda7             938M  133M  758M  15% /home/second
root@popp:~# 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: 0x0000e9fe

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         558     4480000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             558        1045     3905537    5  Extended
/dev/sda5             558         680      976896   82  Linux swap / Solaris
/dev/sda6             680         923     1950720   83  Linux
/dev/sda7             923        1045      975872   83  Linux

Kettaruumi vähendamine

Ühendame vähendatava kettajao lahti

umount /dev/sda6

Samuti kettajao, mida suurendama hakkame

umount /dev/sda7

Kontrollime mõlemad failisüsteemid üle

root@popp:~# fsck -n /dev/sda6
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
/dev/sda6: clean, 7994/121920 files, 56869/487680 blocks
root@popp:~# fsck -n /dev/sda7
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
/dev/sda7: clean, 4160/61056 files, 37871/243968 blocks

Muudame failisüsteemid ext2-ks

root@popp:/usr# tune2fs -O ^has_journal /dev/sda6
tune2fs 1.41.12 (17-May-2010)
root@popp:/usr# tune2fs -O ^has_journal /dev/sda7
tune2fs 1.41.12 (17-May-2010)

Kontrollime failisüsteemi:

root@popp:~# e2fsck -f /dev/sda6
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda6: 7994/121920 files (0.1% non-contiguous), 48668/487680 blocks
root@popp:~# e2fsck -f /dev/sda7
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda7: 4160/61056 files (0.0% non-contiguous), 33770/243968 blocks

Vähendame soovitud failisüsteemi vajaliku suuruseni. Siinjuures tuleb jälgida andmete säilimise pärast, et see ei oleks väiksem, kui viimati kasutuses olnud maht. Antud juhul mitte väiksem, kui 227M ning hetkel vähendame 300MB-ni.

root@popp:~# resize2fs /dev/sda6 300M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/sda6 to 76800 (4k) blocks.
The filesystem on /dev/sda6 is now 76800 blocks long.

Järgmiseks kustutame partitsiooni, ning loome uue ning väiksema. Antud juhul tuleb tähele panna uue partitsiooni loomisel last cylinder väärtust. Selle saame korrutades failisüsteemi plokkide arvu ja plokisuuruse, mille saime failisüsteemi vähendamise väljundist, omavahel ning lisame sellele umbes 5% lisaks, et olla kindel et uus partitsioon oleks piisavalt suur failisüsteemi jaoks. Ehk asendades arvud valemisse: 76800*4*1.05=322560(KB)

root@popp:/usr# fdisk /dev/sda

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').

Command (m for help): d
Partition number (1-6): 6

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (801-923, default 801): 
Using default value 801
Last cylinder, +cylinders or +size{K,M,G} (801-922, default 922): +322560K

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 or after you run partprobe(8) or kpartx(8)
Syncing disks.

Nagu hoiatusest selgus, peame masina taaskäivitama:

reboot now