{"id":2261,"date":"2009-08-01T15:51:32","date_gmt":"2009-08-01T15:51:32","guid":{"rendered":"http:\/\/t.motd.kr\/articles\/2261\/changing-the-default-codepage-of-vfat-without-rebuilding-linux-kernel"},"modified":"2022-12-28T01:44:58","modified_gmt":"2022-12-27T16:44:58","slug":"changing-the-default-codepage-of-vfat-without-rebuilding-linux-kernel","status":"publish","type":"post","link":"https:\/\/vault.motd.kr\/wordpress\/posts\/2261\/changing-the-default-codepage-of-vfat-without-rebuilding-linux-kernel\/","title":{"rendered":"Changing the default codepage of VFAT without rebuilding Linux kernel"},"content":{"rendered":"\n
Since freedesktop.org has moved its disk management facility from HAL<\/span> to DeviceKit-disks (devkit-disks), I could not override the default codepage of a VFAT<\/span> USB<\/span> storage device. DevKit does not allow to mount VFAT<\/span> with the codepage option, and it was a problem to me because I use UTF<\/span>-8 as the default codepage of the Linux partitions while most VFAT<\/span> partiitions and USB<\/span> disks were using CP949 (codepage 949).<\/p>\n\n\n\n A known workaround for this issue is to specify the mount options in \/etc\/fstab explicitly, but it does not scale because USB<\/span> disks change its device path very often, especially when many USB<\/span> devices are plugged in.<\/p>\n\n\n\n Consequently, I wrote a simple script that puts a watch on \/etc\/mtab file and remount VFAT<\/span> with an explicit codepage option if necessary. I start up this watcher script in my \/etc\/rc.local so that I don\u2019t need to care about codepage issues anymore.<\/p>\n\n\n\n Because this script scans for the mtab file every second, you might see some problem when you perform some operation on the mounted VFAT<\/span> too soon, but it shouldn\u2019t be a problem for most cases.<\/p>\n\n\n\n \ub9ac\ub205\uc2a4 \ucee4\ub110\uc744 \ub9ac\ube4c\ub4dc\ud558\uc9c0 \uc54a\uace0 VFAT<\/span> \ub514\ud3f4\ud2b8 \ucf54\ub4dc\ud398\uc774\uc9c0 \ubc14\uafb8\uae30<\/p>\n\n\n\n Freedesktop.org \uac00 \ub514\uc2a4\ud06c \uad00\ub9ac \uae30\ub2a5 \uc81c\uacf5\uc790\ub97c HAL<\/span> \uc5d0\uc11c DeviceKit-disks (devkit-disks) \ub85c \ubcc0\uacbd\ud558\uc5ec \ub354 \uc774\uc0c1 USB<\/span> \ub514\uc2a4\ud06c\uc758 \uae30\ubcf8 \ucf54\ub4dc\ud398\uc774\uc9c0\ub97c \uc9c0\uc815\ud560 \uc218 \uc5c6\uac8c \ub418\uc5c8\uc2b5\ub2c8\ub2e4. DevKit \uc740 VFAT<\/span> \uc744 \ub9c8\uc6b4\ud2b8\ud560 \ub54c codepage \uc635\uc158\uc744 \uc804\ud600 \uc8fc\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \ub54c\ubb38\uc5d0 \ub9ac\ub205\uc2a4 \uae30\ubcf8 \ubb38\uc790\uc14b\uc740 UTF<\/span>-8 \uc73c\ub85c VFAT<\/span> \ubb38\uc790\uc14b\uc740 CP949 (\ucf54\ub4dc\ud398\uc774\uc9c0 949) \ub85c \uc0ac\uc6a9\ud558\ub294 \uacbd\uc6b0\uc5d0\ub294 \ubb38\uc81c\uac00 \ub429\ub2c8\ub2e4.<\/p>\n\n\n\n \uc54c\ub824\uc9c4 \ud574\uacb0\ucc45\uc740 \/etc\/fstab \uc5d0 \ub9c8\uc6b4\ud2b8 \uc635\uc158\uc744 \uc9c1\uc811 \uc801\uc5b4 \uc8fc\ub294 \uac83\uc774 \uc788\uc73c\ub098, \ub9ce\uc740 USB<\/span> \uc7a5\uce58\uac00 \uc5f0\uacb0\ub418\uc5b4 \uc788\ub294 \uacbd\uc6b0 \uc7a5\uce58\uc758 \uacbd\ub85c\uac00 \uc790\uc8fc \ubc14\ub00c\uae30 \ub54c\ubb38\uc5d0 \uc720\uc5f0\ud558\uc9c0\uac00 \ubabb\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n \uadf8\ub798\uc11c \/etc\/mtab \ub97c \ubaa8\ub2c8\ud130\ub9c1\ud558\uace0 \uc788\ub2e4\uac00 \ud544\uc694\ud55c \uacbd\uc6b0 codepage \uc635\uc158\uc744 \uba85\uc2dc\ud574 VFAT<\/span> \uc744 \ub2e4\uc2dc \ub9c8\uc6b4\ud2b8\ud574 \uc8fc\ub294 \uc2a4\ud06c\ub9bd\ud2b8\ub97c \uc791\uc131\ud588\uc2b5\ub2c8\ub2e4. \uc800\ub294 \uc774 \uac10\uc2dc \uc2a4\ud06c\ub9bd\ud2b8\ub97c \/etc\/rc.local \uc5d0\uc11c \uc2dc\uc791\ud574\uc11c \ucf54\ub4dc\ud398\uc774\uc9c0 \uc774\uc288\ub97c \ub354 \uc774\uc0c1 \uc2e0\uacbd\uc4f8 \uc77c\uc774 \uc5c6\ub3c4\ub85d \ud588\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n \uc774 \uc2a4\ud06c\ub9bd\ud2b8\ub294 mtab \ud30c\uc77c\uc744 1 \ucd08\uc5d0 \ud55c \ubc88\uc529 \uc2a4\uce94\ud558\ubbc0\ub85c \ub9c8\uc6b4\ud2b8\ub41c VFAT<\/span> \uc5d0 \ub108\ubb34 \uc77c\ucc0d \uc811\uadfc\ud558\ub824 \ud560 \ub54c \ubb38\uc81c\uac00 \uc0dd\uae38 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ud558\uc9c0\ub9cc \ub300\ubd80\ubd84\uc758 \uacbd\uc6b0\uc5d0\ub294 \ubcc4 \ubb38\uc81c\uac00 \uc548 \ub420 \ub4ef \ud558\ub124\uc694.<\/p>\n","protected":false},"excerpt":{"rendered":" Since freedesktop.org has moved its disk management facility from HAL to DeviceKit-disks (devkit-disks), I could not override the default codepage of a VFAT USB storage device. DevKit does not allow to mount VFAT with the codepage option, and it was a problem to me because I use UTF-8 as the default codepage of the Linux… Continue reading #!\/bin\/sh\n# \/usr\/local\/bin\/vfat-watch\n# Exit if running already.\nif [ \"x`pgrep -of 'vfat-watch'`\" != \"x$\" ]; then\n exit 1\nfi\nwhile true; do\n cat \/etc\/mtab | grep vfat | grep -v codepage | cut -d' ' -f1 | while read -r FS; do\n # Choose your preferred codepage. 949 = Korean\n mount -o remount,codepage=949 \"$FS\"\n done\n sleep 1\ndone &<\/code><\/pre>\n\n\n\n
#!\/bin\/sh\n# \/usr\/local\/bin\/vfat-watch\n# Exit if running already.\nif [ \"x`pgrep -of 'vfat-watch'`\" != \"x$\" ]; then\n exit 1\nfi\nwhile true; do\n cat \/etc\/mtab | grep vfat | grep -v codepage | cut -d' ' -f1 | while read -r FS; do\n # Choose your preferred codepage. 949 = Korean\n mount -o remount,codepage=949 \"$FS\"\n done\n sleep 1\ndone &<\/code><\/pre>\n\n\n\n