it:server:resize-partition

Toto je starší verze dokumentu!


Resize partition

Potřeboval jsem rozšířit disk na serveru. Server mám virtuální u Nethost. Jakmile mi přidali volného místa na disku, potřeboval jsem v operačním systému zvětšit partitionu. Samozřejmě jsem to potřeboval za běhu a bez ztráty dat.

V mém případě mám disk /dev/sda a partitionu /dev/sda1.

Po konzultaci s Nethostem jsem použil následující řešení:

root@server:~# parted /dev/sda                                                                        
GNU Parted 3.4                                                                                        
Using /dev/sda                                                                                        
Welcome to GNU Parted! Type 'help' to view a list of commands.                                        
(parted) list                                                                                         
  align-check TYPE N                       check partition N for TYPE(min|opt) alignment              
  help [COMMAND]                           print general help, or help on COMMAND                     
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)                   
  mkpart PART-TYPE [FS-TYPE] START END     make a partition                                           
  name NUMBER NAME                         name partition NUMBER as NAME                              
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space,
        all found partitions, or a particular partition                                               
  quit                                     exit program                                               
  rescue START END                         rescue a lost partition near START and END                 
  resizepart NUMBER END                    resize partition NUMBER                                    
  rm NUMBER                                delete partition NUMBER                                    
  select DEVICE                            choose the device to edit                                  
  disk_set FLAG STATE                      change the FLAG on selected device                         
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device                
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER                        
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER               
  unit UNIT                                set the default unit to UNIT                               
  version                                  display the version number and copyright information of GNU
        Parted                                                                                        
(parted) unit s                                                                                       
(parted) print free                                                                                   
Model: QEMU nhhdd1419000 (scsi)                                                                       
Disk /dev/sda: 117194752s                                                                             
Sector size (logical/physical): 512B/512B                                                             
Partition Table: msdos                                                                                
Disk Flags:                                                                                           
 
Number  Start      End         Size       Type     File system  Flags                                 
        2s         2047s       2046s               Free Space                                         
 1      2048s      97654783s   97652736s  primary  ext4         boot                                  
        97654784s  117194751s  19539968s           Free Space                                         
 
(parted) resizepart 1 117194751                                                                       
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?                        
Yes/No? Yes                                                                                           
(parted) quit                                                                                         
Information: You may need to update /etc/fstab.                                                       
 
root@server:~# resize2fs /dev/sda                                                                     
sda   sda1                                                                                            
root@server:~# resize2fs /dev/sda1                                                                    
resize2fs 1.46.2 (28-Feb-2021)                                                                        
Filesystem at /dev/sda1 is mounted on /; on-line resizing required                                    
old_desc_blocks = 6, new_desc_blocks = 7                                                              
The filesystem on /dev/sda1 is now 14649088 (4k) blocks long.
  • it/server/resize-partition.1685561647.txt.gz
  • Poslední úprava: 2023/05/31 19:34
  • autor: Petr Nosek