Ir ao conteúdo
  • Cadastre-se

Linha de comando: redimensionando partição NTFS travada para o GParted


alexandre.mbm
Ir à solução Resolvido por alexandre.mbm,

Posts recomendados

  • Membro VIP

Nota: este tópico começou com o título "CHKDSK sem Windows" e depois foi renomeado.
 
O GParted não está deixando eu reduzir uma partição NTFS. Mas o ntfs-3g (ntfsprogs) está instalado. Então eu fui ver por linha de comando:

ubuntu@ubuntu:~$ sudo ntfsresize -ni /dev/sda2ntfsresize v2014.2.15 (libntfs-3g)Device name        : /dev/sda2NTFS volume version: 3.1Cluster size       : 4096 bytesCurrent volume size: 248484196864 bytes (248485 MB)Current device size: 248484200448 bytes (248485 MB)ERROR: This software has detected that the disk has at least 5 bad sectors.***************************************************************************** WARNING: The disk has bad sector. This means physical damage on the disk ** surface caused by deterioration, manufacturing faults or other reason.   ** The reliability of the disk may stay stable or degrade fast. We suggest  ** making a full backup urgently by running 'ntfsclone --rescue ...' then   ** run 'chkdsk /f /r' on Windows and rebooot it TWICE! Then you can resize  ** NTFS safely by additionally using the --bad-sectors option of ntfsresize.*****************************************************************************ubuntu@ubuntu:~$

Na há mais Windows na partição. Apaguei todos os arquivos deixando apenas os pessoais. Inclusive retirei a flag boot.
 
Iniciei com um disco do Windows e, no Prompt de Comando (modo de reparação), passei o chkdsk c: /f /r. Acontece que eu não fiz os dois reboots seguintes, da instrução acima. Como, se não tem Windows? Invés disso, iniciei o Ubuntu do pendrive outra vez. Nada tinha mudado, a não ser que agora existe o diretório found.000. O GParted continua incapaz de alterar a partição, e o ntfsresize continua a retornar o que está acima.
 
O que fazer?
 
Enquanto ninguém responde eu vou ver se dois boots na mídia ótica surte algum efeito.
 
Curioso que existe — e já existia — um diretório que não pode ser apagado, no C:\.
 
Será que eu já devo simplesmente "fechar os olhos" e usar a opção --bad-sectors no ntfsresize?
 
Update 1 ‒ 1h58m de domingo, 15 de março de 2014
 
Entrei no Prompt de Comando do CD do Windows uma segunda vez e fiz chkdsk c: /x /f /r. Ele passou sem necessitar de correções. Ou seja, dá pra assumir que está tudo OK com o sistema de arquivos.
 
Então fiz uma simulação bem sucedida:

ubuntu@ubuntu:~$ sudo ntfsresize -n -b -s 102400M /dev/sda2ntfsresize v2014.2.15 (libntfs-3g)Device name        : /dev/sda2NTFS volume version: 3.1Cluster size       : 4096 bytesCurrent volume size: 248484196864 bytes (248485 MB)Current device size: 248484200448 bytes (248485 MB)New volume size    : 102399996416 bytes (102400 MB)WARNING: This software has detected that the disk has at least 5 bad sectors.WARNING: Bad sectors can cause reliability problems and massive data loss!!!Checking filesystem consistency ...100.00 percent completedAccounting clusters ...Space in use       : 74723 MB (30,1%)Collecting resizing constraints ...Needed relocations : 11835105 (48477 MB)Schedule chkdsk for NTFS consistency check at Windows boot time ...Resetting $LogFile ... (this might take a while)Relocating needed data ...Updating $BadClust file ...Updating $Bitmap file ...Non-positive free clusters (0)!Updating Boot record ...The read-only test run ended successfully.ubuntu@ubuntu:~$

Update 2 ‒ 3h05m de domingo, 15 de março de 2014
 
Finalmente eu executei sem a opção -n e deixou de ser uma simulação:

ubuntu@ubuntu:~$ sudo ntfsresize -b -s 102400M /dev/sda2ntfsresize v2014.2.15 (libntfs-3g)Device name : /dev/sda2NTFS volume version: 3.1Cluster size : 4096 bytesCurrent volume size: 248484196864 bytes (248485 MB)Current device size: 248484200448 bytes (248485 MB)New volume size : 102399996416 bytes (102400 MB)WARNING: This software has detected that the disk has at least 5 bad sectors.WARNING: Bad sectors can cause reliability problems and massive data loss!!!Checking filesystem consistency ...100.00 percent completedAccounting clusters ...Space in use : 74723 MB (30,1%)Collecting resizing constraints ...Needed relocations : 11835105 (48477 MB)WARNING: Every sanity check passed and only the dangerous operations left.Make sure that important data has been backed up! Power outage or computercrash may result major data loss!Are you sure you want to proceed (y/[n])? ySchedule chkdsk for NTFS consistency check at Windows boot time ...Resetting $LogFile ... (this might take a while)Relocating needed data ...Updating $BadClust file ...Updating $Bitmap file ...Non-positive free clusters (0)!Updating Boot record ...Syncing device ...Successfully resized NTFS on device '/dev/sda2'.You can go on to shrink the device for example with Linux fdisk.IMPORTANT: When recreating the partition, make sure that you1) create it at the same disk sector (use sector as the unit!)2) create it with the same partition type (usually 7, HPFS/NTFS)3) do not make it smaller than the new NTFS filesystem size4) set the bootable flag for the partition if it existed beforeOtherwise you won't be able to access NTFS or can't boot from the disk!If you make a mistake and don't have a partition table backup then youcan recover the partition table by TestDisk or Parted's rescue mode.ubuntu@ubuntu:~$

A execução real é muito diferente da simulação! Invés de apenas 2 minutos de operação somente-leitura, foram quanse 50 minutos de escrita no sistema de arquivos. Realmente É MUITA CHANCE PRA ALGO DAR ERRADO! Poderia ter faltado energia, ou o mal contato no cabo da fonte do notebook poderia ter dado seu alô. Foi quase uma hora de tensão. Por via das dúvidas, eu preferi me afastar do teclado e olhar de longe.
 
Agora, lendo a mensagem que foi exposta no final do procedimento (veja acima), acabo de entender que o ntfsresize apenas fez uma espécie de desfragmentação básica, realocando 48.477 MB para dentro dos 102.400 MB pretendido. Eu terei de manualmente destruir a partição e recriá-la com o novo tamanho. Usarei o fdisk observando estas orientações:
 

Agora você pode encolher o dispositivo, por exemplo, usando o fdisk do Linux.
IMPORTANTE: quando estiver recriando a partição, certifique-se de:
1) criá-la no mesmo setor do disco (use setor como unidade!)
2) criá-la com o mesmo tipo (normalmente 7, HPFS/NTFS)
3) não fazê-la menor do que o novo tamanho do sistema de arquivos NTFS
4) configurar a flag "boot" para a partição, se ela existia antes
Caso contrário, você não estará apto a acessar NTFS ou você não poderá dar boot no disco!
Se você cometer um erro e não tiver um backup da tabela de partição, então você ainda poderá recuperá-la usando o TestDisk ou o modo de recuperação do Parted.

 
Farei backup da tabela de partição (2) no pendrive, antes prosseguir. Também resta-me estudar o fdisk.
 
Update 3 ‒ 3h36m de domingo, 15 de março de 2014
 
Informações sobre a partição antes de encurtá-la:
 
post-435193-0-10469700-1426401460_thumb.

ubuntu@ubuntu:~$ sudo fdisk -l /dev/sdaDisco /dev/sda: 250.1 GB, 250059350016 bytes255 cabeças, 63 setores/trilhas, 30401 cilindros, total de 488397168 setoresUnidades = setores de 1 * 512 = 512 bytesTamanho do setor (lógico/físico): 512 bytes / 512 bytesTamanho da E/S (mínimo/ideal): 512 bytes / 512 bytesIdentificador do disco: 0x87438bb0Dispositivo Boot      Início        Fim      Blocos   Id  Sistema/dev/sda1            2048     3074047     1536000   27  WinRE de NTFS oculto/dev/sda2         3074048   488394751   242660352    7  HPFS/NTFS/exFATubuntu@ubuntu:~$

Update 4 ‒ 4h26m de domingo, 15 de março de 2014

Indicações de que estamos no caminho certo:

No man ntfsresize:

   Shrinkage       If you wish to shrink an NTFS partition, first use ntfsresize to shrink       the  size  of the filesystem. Then you could use fdisk(8) to shrink the       size of the partition by deleting the partition and recreating it  with       the  smaller size.  Do not make the partition smaller than the new size       of NTFS otherwise you won't be able to boot. If  you  did  so  notwith‐       standing then just recreate the partition to be as large as NTFS.

Porém:

ubuntu@ubuntu:~$ sudo ntfsresize -nfi /dev/sda2ntfsresize v2014.2.15 (libntfs-3g)Device name        : /dev/sda2NTFS volume version: 3.1Cluster size       : 4096 bytesCurrent volume size: 102399996416 bytes (102400 MB)Current device size: 248484200448 bytes (248485 MB)Checking filesystem consistency ...Outside of the volume reference for inode 545411 at 26160644:479984Outside of the volume reference for inode 545411 at 27218588:441092Outside of the volume reference for inode 830772 at 25761652:8Outside of the volume reference for inode 830772 at 25761668:8Outside of the volume reference for inode 830772 at 25761732:8Outside of the volume reference for inode 830772 at 25761748:8Outside of the volume reference for inode 830772 at 25761780:8Outside of the volume reference for inode 830772 at 25761812:8Outside of the volume reference for inode 830772 at 25761956:8Outside of the volume reference for inode 830772 at 25761972:8100.00 percent completedERROR: Filesystem check failed!ERROR: 922028 clusters are referenced outside of the volume.NTFS is inconsistent. Run chkdsk /f on Windows then reboot it TWICE!The usage of the /f parameter is very IMPORTANT! No modification wasand will be made to NTFS by this software until it gets repaired.ubuntu@ubuntu:~$

Apesar de que no man do ntfsresize tem:

              Please  note, ntfsresize always marks the filesystem for consis‐              tency check before a real resize operation and  it  leaves  that              way for extra safety. Thus if NTFS was marked by ntfsresize then              it's safe to use this option. If  you  need  to  resize  several              times  without  booting into Windows between each resizing steps              then you must use this option.

Por via das dúvidas, vou inciar o CD uma terceira vez e rodar chkdsk c: /f, pra ver como fica.
 

Update 5 ‒ 4h56m de domingo, 15 de março de 2014

 

O CHKDSK fez correções. Excluiu registros de atributos corrompidos — (128, "").

 

Agora o ntfsresize retorna sem forçar e sem erros:

ubuntu@ubuntu:~$ sudo ntfsresize -ni /dev/sda2ntfsresize v2014.2.15 (libntfs-3g)Device name        : /dev/sda2NTFS volume version: 3.1Cluster size       : 4096 bytesCurrent volume size: 102399996416 bytes (102400 MB)Current device size: 248484200448 bytes (248485 MB)Checking filesystem consistency ...100.00 percent completedAccounting clusters ...Space in use       : 70349 MB (68,7%)Collecting resizing constraints ...You might resize at 70348808192 bytes or 70349 MB (freeing 32051 MB).Please make a test run using both the -n and -s options before real resizing!ubuntu@ubuntu:~$

Do que está acima, a informação relevante é o tamanho do volume (diminuído).

 

O melhor: apesar do GParted continuar com o um aviso (no sinal de interrogação vermelho), agora está parecendo que ele vai permitir o redimensionamento. Agora ele reconhece o volume.

 

post-435193-0-77893100-1426406753_thumb.

 

O aviso mudou:

 

post-435193-0-17754800-1426407232_thumb.

 

Vou preferir tentar usá-lo do que ir para a linha de comando com o fdisk. Eu só tenho de tomar cuidado para não redimensionar para um tamanho que "estrangule" o volume.

Link para o comentário
Compartilhar em outros sites

  • Membro VIP
  • Solução

No final das contas, com toda uma "depuração" que fora realizada mediante várias execuções e paramentrizações dos comandos ntfsresize e chkdsk (CD do Windows), o problema foi resolvido ainda com o amigável GParted.

 

post-435193-0-02250600-1426408341_thumb.

 

post-435193-0-06526200-1426408351_thumb.

 

post-435193-0-46951200-1426408496_thumb.

 

O disco rígido agora tem 130 GB para GNU/Linux!

 

Ainda bem que não faltou energia em algum momento...

 

E tudo isso foi feito a partir de um Ubuntu 14.04.2 LTS em pendrive com escrita, customizado.

  • Curtir 1
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!