기본 콘텐츠로 건너뛰기

[Ubuntu] How To Fix A Corrupted Windows NTFS Filesystem With Ubuntu

source: http://askubuntu.com/questions/59064/how-to-run-a-checkdisk

How many of you have had that sinking feeling as your PC boots up? You know, a slight niggle in the back of your mind that says “this is taking longer than usual” before Windows drops dead in front of you, and refuses to play ball.Me too, and much of the time the original Windows CD/DVD/USB you used in your original install can’t fix the problem. You need something else. Something like a whole operating system, either installed on a separate partition or in Live CD/USB format. Enter Ubuntu!

There’s a good few reasons to have Ubuntu on a CD or USB stick somewhere in a draw. It’s free, to start with. You don’t need to install it to use it, and it’s great for accessing a butchered Windows partition ““ even if it’s just to get your precious documents back before a format.
When it comes to fixing your broken Windows install then Ubuntu has its uses there too. If you happen to break your registry or master boot record, then fear not ““ all is not lost. This technique should work on any Ubuntu-based Linux distributions.

Download, Install & Boot Ubuntu

Those of you who already have a dual-boot Ubuntu and Windows machine can skip this step.
If you’ve not got a Live USB stick then you’re going to need to get hold of one. UNetbootin is a useful tool which enables you to create a USB stick with a bootable version of your favourite open source operating system preloaded. If you’d prefer to use a CD, download an Ubuntu disk image and burn it with ImgBurn.
ubuntu fixing ntfs filesystem
If you’re dual-booting, then this is a simple step of choosing Ubuntu over Windows at boot. For Live USB sticks and CDs you’re going to need to enter the BIOS setup as your PC boots (usually by pressing F2 or Del) and arrange your boot devices to prioritize your USB device or CD drive to boot before your main hard drive.
If you’ve done everything correctly you’ll see the UNetbootin bootloader appear. From here you’ll want to boot directly into the operating system. After a minute or two you’ll see the desktop appear, and we’re ready to begin.

Fixing A Corrupted Windows NTFS Partition

Luckily you can schedule an NTFS consistency check within Ubuntu to attempt to repair your tattered Windows partition, but you’re going to need to install a couple of things. It is worth mentioning that this should work with any NTFS drive that refuses to mount in Ubuntu too. Open a Terminal window by clicking Applications, Accessories and then Terminal.
First install NTFS-3G by typing this command:
sudo apt-get install ntfs-3g
Enter your password and hit Enter on your keyboard. Next install NTFSProgs in the same way:
sudo apt-get install ntfsprogs
ubuntu fixing ntfs filesystem
Now with both of those tools at your disposal, you can set about fixing Windows. First locate your Windows partition. In the Terminal type:
sudo fdisk -l
rescue ntfs filesystem from linux
You’re looking for an entry that looks like this:
/dev/sda2   *         638       12312    93773824    7  HPFS/NTFS
The important bit is the /dev/sda2 which tells us where the Windows partition is mounted. HPFS/NTFS lets us know that the partition is a Microsoft Windows formatted device, and that little star denotes that this is a bootable partition.
So in my case /dev/sda2 means that Windows is on sda (my internal hard drive) and that it’s partition 2 that I want to play around with.
Armed with this information you want to use NTFSProgs to attempt to fix the partition. In your Terminal window type:
sudo ntfsfix /dev/<device name>
rescue ntfs filesystem from linux
Replace <device name> with your Windows partition (e.g. /dev/sda2) and enter your password followed by Enter. Your drive will now be mounted, checked for consistency and any errors found should be fixed. Restart your PC to assess the situation, if all goes well you’ll see Windows.

Fixing A Corrupt Master Boot Record

If you’ve got a problem with Windows’ oh-so-important boot record then you can also fix that from within Ubuntu too. Assuming you’ve already booted into Ubuntu, open up Terminal and install lilo by typing:
sudo apt-get install lilo
Enter your password to proceed with the installation, you’ll get a few warnings pop-up along the way.
If you followed the first part of this tutorial you’ll know which partition Windows is installed on, if you missed it type:
sudo fdisk -l
Find the HPFS/NTFS partition that relates to your Windows install, and type:
sudo lilo -M /dev/ mbr
Replace <device name> with your Windows partition (e.g. /dev/sda2) and hit Enter. Ubuntu will attempt to restore your master boot record. You’ll probably want to restart your machine now, just make sure you take any Live CD/USB devices out as you do.

Conclusion

If you’re still having problems with a Windows install, and you’ve tried everything then don’t forget you can mount the partition and rescue as much data as you think you’ll need. Using the terminal, enter:
sudo mkdir /media/windows
sudo ntfs-3g -o force,rw /dev/<device name> /media/windows
Replace <device name> with your Windows partition location and the drive should pop-up on your desktop.
rescue ntfs filesystem from linux
Has Ubuntu saved your bacon recently? Do you dual-boot with Windows? Thinking about making a Live CD just in case? Let us know below.

--------------------------------------------------------------------------------------------------------------------------
source:http://wmarkito.wordpress.com/2010/12/29/how-to-fix-mftmirr-does-not-match-mft-record-0/

How to fix ‘$MFTMirr does not match $MFT (record 0)’

Sometimes, when you are executing a file transfer between your computer hard drive and an external drive and your computer shutdown for some reason (in my case, no battery/ac power) it’s pretty common to get some errors on external drives that uses NTFS as they file system.
The most common message is:
Error mounting: mount exited with exit code 13: $MFTMirr does not match $MFT (record 0).
Failed to mount ‘/dev/sdb3′: Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it’s a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the ‘dmraid’ documentation
for more details.
One workaround for this issue is to do as the message says, boot on Windows and try to use the awesome NTFS tool that Windows offer. But a perfect solution for a Linux users is to use the ntfsprogs utility.
UPDATE: On some recent Linux releases, you need to install ntfs-3g utilties.  Try sudo apt-get install ntfs-3g or download from http://www.tuxera.com/community/ntfs-3g-download/
ntfsprogs is a suite of NTFS utilities based around a shared library. The tools are available for free and come with full source code.
  • mkntfs: Create an NTFS volume on a partition
  • ntfscat: Print a file on the standard output
  • ntfsclone: Efficiently backup/restore a volume at the sector level
  • ntfscluster: Given a cluster, or sector, find the file
  • ntfsfix: Forces Windows to check NTFS at boot time
  • ntfsinfo: Dump a file’s attributes, completely
  • ntfslabel: Display or set a volume’s label
  • ntfslib: Move all the common code into a shared library
  • ntfsls: List directory contents
  • ntfsresize: Resize an NTFS volume
  • ntfsundelete: Find files that have been deleted and recover them
  • ntfswipe: Write zeros over the unused parts of the disk
  • ntfsdefrag: Defragment files, directories and the MFT
  • ntfsck: Perform consistancy checks on a volume
  • nttools: Command-line tools to view/change an offline NTFS volume, e.g. ntfscp, ntfsgrep, ntfstouch, ntfsrm, ntfsrmdir, ntfsmkdir
  • ntfsdiskedit: Walk the tree of NTFS ondisk structures (and alter them)
Be careful with these utilities, they might damage the filesystem, or your hard disk !
With ntfsprogs installed (sudo apt-get install ntfsprogs) you should execute the following commands in a terminal:
sudo ntfsfix /dev/partitionName
After this command you should expect the following output:
~$ sudo ntfsfix /dev/sdb3
Mounting volume... FAILED
Attempting to correct errors...
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... FAILED
Correcting differences in $MFTMirr record 0...OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
NTFS volume version is 3.1.
NTFS partition /dev/sdb3 was processed successfully.
After this step you should be able to access your external drive partition as usual, mount or use nautilus to access your files.

댓글

이 블로그의 인기 게시물

[인코딩] MS949부터 유니코드까지

UHC = Unified Hangul Code = 통합형 한글 코드 = ks_c_5601-1987 이는 MS사가 기존 한글 2,350자밖에 지원하지 않던 KS X 1001이라는 한국 산업 표준 문자세트를 확장해 만든 것으로, 원래 문자세트의 기존 내용은 보존한 상태로 앞뒤에 부족한 부분을 채워넣었다. (따라서 KS X 1001에 대한 하위 호환성을 가짐) 그럼, cp949는 무엇일까? cp949는 본래 코드 페이지(code page)라는 뜻이라 문자세트라 생각하기 십상이지만, 실제로는 인코딩 방식이다. 즉, MS사가 만든 "확장 완성형 한글 ( 공식명칭 ks_c_5601-1987 ) "이라는 문자세트를 인코딩하는 MS사 만의 방식인 셈이다. cp949 인코딩은 표준 인코딩이 아니라, 인터넷 상의 문자 송수신에 사용되지는 않는다. 하지만, "확장 완성형 한글" 자체가 "완성형 한글"에 대한 하위 호환성을 고려해 고안됐듯, cp949는 euc-kr에 대해 (하위) 호환성을 가진다. 즉 cp949는 euc-kr을 포괄한다. 따라서, 윈도우즈에서 작성되어 cp949로 인코딩 되어있는 한글 문서들(txt, jsp 등등)은 사실, euc-kr 인코딩 방식으로 인터넷 전송이 가능하다. 아니, euc-kr로 전송해야만 한다.(UTF-8 인코딩도 있는데 이것은 엄밀히 말해서 한국어 인코딩은 아니고 전세계의 모든 문자들을 한꺼번에 인코딩하는 것이므로 euc-kr이 한국어 문자세트를 인코딩할 수 있는 유일한 방식임은 변하지 않는 사실이다.) 물론 이를 받아보는 사람도 euc-kr로 디코딩을 해야만 문자가 깨지지 않을 것이다. KS X 1001을 인코딩하는 표준 방식은 euc-kr이며 인터넷 상에서 사용 가능하며, 또한 인터넷상에서 문자를 송수신할때만 사용.(로컬하드에 저장하는데 사용하는 인코딩방식으로는 쓰이지 않는 듯하나, *nix계열의 운영체제에서는 LANG을 euc-kr로 설정 가능하기도 한걸

[linux] 뻔하지 않은 파일 퍼미션(file permissions) 끄적임. 정말 속속들이 아니?

1. [특수w]내 명의의 디렉토리라면 제아무리 루트가 만든 파일에 rwxrwxrwx 퍼미션이라 할지라도 맘대로 지울 수 있다. 즉 내 폴더안의 파일은 뭐든 지울 수 있다. 2. [일반rx]하지만 읽기와 쓰기는 other의 권한을 따른다. 3.[일반rwx]단 남의 계정 폴더는 그 폴더의 퍼미션을 따른다. 4.[일반]만약 굳이 sudo로 내 소유로 파일을 넣어놓더라도 달라지는건 없고, 단지 그 폴더의 other퍼미션에 write권한이 있으면 파일을 만들고 삭제할 수 있다. 5.디렉토리의 r권한은 내부의 파일이름 정도만 볼 수있다. 하지만 ls 명령의 경우 소유자, 그룹, 파일크기 등의 정보를 보는 명령어므로 정상적인 실행은 불가능하고, 부분적으로 실행됨. frank@localhost:/export/frankdir$ ls rootdir/ ls: cannot access rootdir/root: 허가 거부 ls: cannot access rootdir/fa: 허가 거부 fa  root #이처럼 속한 파일(폴더)만 딸랑 보여준다. frank@localhost:/export/frankdir$ ls -al rootdir/ # al옵션이 모두 물음표 처리된다.. ls: cannot access rootdir/root: 허가 거부 ls: cannot access rootdir/..: 허가 거부 ls: cannot access rootdir/.: 허가 거부 ls: cannot access rootdir/fa: 허가 거부 합계 0 d????????? ? ? ? ?             ? . d????????? ? ? ? ?             ? .. -????????? ? ? ? ?             ? fa -????????? ? ? ? ?             ? root 하지만 웃긴건, r에는 읽기 기능이 가능하므로 그 폴더 안으로 cd가 되는 x권한이 없더라도 어떤 파일이 있는지 목록 정도는 알 수 있다. 하지만 r이라고

[hooking, 후킹, 훅킹] Hooking이란?

source: http://jinhokwon.blogspot.kr/2013/01/hooking.html Hooking 이란? [출처] http://blog.daum.net/guyya/2444691 훅킹(Hooking)이란 이미 작성되어 있는 코드의 특정 지점을 가로채서 동작 방식에 변화를 주는 일체의 기술 이다. 훅이란 낚시바늘같은 갈고리 모양을 가지는데 여기서는 코드의 중간 부분을 낚아채는 도구라는 뜻으로 사용된다. 대상 코드의 소스를 수정하지 않고 원하는 동작을 하도록 해야 하므로 기술적으로 어렵기도 하고 운영체제의 통상적인 실행 흐름을 조작해야 하므로 때로는 위험하기도 하다. 훅킹을 하는 방법에는 여러 가지가 있는데 과거 도스 시절에 흔히 사용하던 인터럽터 가로채기 기법이나 바로 앞에서 알아본 서브클래싱도 훅킹 기법의 하나라고 할 수 있다. 이외에도 미리 약속된 레지스트리 위치에 훅 DLL의 이름을 적어 주거나 BHO(Browser Helper Object)나 응용 프로그램 고유의 추가 DLL(Add in)을 등록하는 간단한 방법도 있고 PE 파일의 임포트 함수 테이블을 자신의 함수로 변경하기, CreateRemoteThread 함수로 다른 프로세스의 주소 공간에 DLL을 주입(Injection)하는 방법, 메모리의 표준 함수 주소를 덮어 쓰는 꽤 어려운 방법들도 있다. 이런 고급 훅킹 기술은 이 책의 범위를 벗어나므로 여기서는 소개만 하고 다루지는 않기로 한다. 이 절에서 알아볼 메시지 훅은 윈도우로 전달되는 메시지를 가로채는 기법으로 다양한 훅킹 방법중의 하나이다. 메시지 기반의 윈도우즈에서는 운영체제와 응용 프로그램, 또는 응용 프로그램 사이나 응용 프로그램 내부의 컨트롤끼리도 많은 메시지들을 주고 받는다. 훅(Hook)이란 메시지가 목표 윈도우로 전달되기 전에 메시지를 가로채는 특수한 프로시저이다. 오고 가는 메시지를 감시하기 위한 일종의 덫(Trap)인 셈인데 일단 응용 프로그램이 훅 프로시저를 설치하면 메시지가 윈도우로 보내지기