Blog

Blog

iMac 27″ Mid 2011 OS reinstallation

iMac 27" Mid 2011 OS reinstallation

In order to reinstall OS, I searched Internet, and no one tell the truth, let me spent a few hours. I'm also not sure my method will work later or not. Need to think a way to create local bootable disk.

Keyboard and Mouse

I don't have wired apple keyboard and mouse, so used Windows keyboard. It doesn't have Command key, but searching internet, found the Intel iMac can use Command or Alt. Yes, Alt works, can display boot option.

Installation Method

Missing installation CD (Failed)

After a few relocation, I could not find the installation CD, it is at least hard to find, decided to create an installation USB.

Installation USB (Failed)

My new iMac mini has OS Big Sur, I tried methods given by Apple, none of them can work.

I created Big Sur bootable USB, but when tried to install, gave me stop sign.

I tried to click the links to download old MacOS from Apple, they don't work at all.

I tried to download OS image from other website, they can not be executed and run Apple given command, because they are for different OS.

I tried use Daemon Tools to create bootable USB from dmg file, in fact, not working.

Internet (Good)

When I kept finding methods to create bootable image, suddenly, the iMac display installation utilities after boot, which means installation can be continue without installation media, this is good feature of iMac.

Disk to be installed

Got funny issue, can not detect my SSD, I thought the SATA connection issue. Open it and reconnected it, tested on external USB, suddenly found the disk can be detected by Disk Utility. Then thought again, noticed that the disk needs to be erased.

OS upgrade and patching

After installation completed, it is running Mount Lion, very old OS, then App Store update got issue, can not update software patch.

After search internet, found High Sierra can be installed, then clicked on Apple OS installation link which was work before, it works.

Not completed, there are quite number of patches to be installed, although take long time, the actual installation time reported by installation process is much longer, about 15 mintues reduced to two or three minutes, this is the benefit of SSD disk.

Backup

To avoid spending too much time next time, I decided to create installation media image and perform backup.

After opened time machine disk selection window, the AFP enabled NAS immediately appear, but not the SMB only NAS. Manual mapping/accessing of disk is required before Time machine could see it.

El Capitan:

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia -

Appendices

Media Creation

The commands are given by Apple as below for media creation.

Beware: They can not work with OS which is different than current.

Big Sur:*

sudo /Applications/Install\ macOS\ Big\ Sur.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

Catalina:*

sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

Mojave:*

sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

High Sierra:*

sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

References

How to create a bootable installer for macOS

Buzzing noise and hard to turn on from iMac 27′

Buzzing Noise from iMac 27'

Got buzzing noise from top left corner, and very hard to turn on, power button may or may not response.

The fan noise also comes from bottom right corner, thinking to replace a new one.

Issues

The power button got issue long ago, sometimes can not work, sometimes can. I think after disconnected from power, maybe will be ok later. I thought it could be bottom connection issue.

After moved iMac into a quiet room, I heard buzzing noise from top left corner, I started believe the power supply got issue.

Plan

Replace power supply later together with fan.

References

IMAC Buzzing Noise From Top Left Corner FIXED!! / Replace Power Supply

iMac 27″ Video Card Repair Using Heat Gun

iMac 27" Video Card Repair Using Heat Gun

Refering to some YouTube video, I tried to repair my iMac 27" (Mid 2011) Video Card, because my iMac could not boot and only apple logo appears. Steps as below

Hardware Info

Information
Identifier iMac12,2
Model A1312 (EMC 2429)
Family iMac (27-inch, Mid 2011)
CPU 3.4 GHz Intel Core i7
Graphic AMD Radeon HD 6970M 2048 MB

Steps

Take out glass panel

Use sucker to take it out.

Take out screen

Got 8 screws.

Take out power supply

Power Supply Cable Connectors

Power Supply Screws

Left of Power Supply

Take out CDROM Drive

CD Drive

CD Temperature Sensor

Take out fan

Fan

Fan (no screw)

Take out main board

Mainboard Battery

Mainboard Screws

Mainboard Below Fan

Below Fan

Below Fan Cables

Bottom

Infra-ray

Mainboard Wifi

Speaker

Speaker Cable

Speaker Connection

Just for info

Battery

Take out main board back cable

Mainboard Back

Mainboard Back Unplug

Take out video card

Video Fan

Right Top Video Card

GPU

GPU Back

GPU Heat Sink

GPU Heat Sink Screws

GPU Screws

GPU no Screw

Damages

The video card to LCD screen cable damaged, bought new one, waiting for delivery.

Damaged Cable

LCD Cable

Working now

Oct 13, After purchased cable, replace it, works immeditially, then continue OS reinstallation.

Future use

Due to this machine is too hot, I think better only use it in aircon room, and no background service should be executed.

References

My iMac is different model as below, but similar.

A1312 iMac GPU Replacement
Late 2009 iMac 27" Video Card Repair — 4850 — 2nd Bake

TODO: Move dataset to another zpool in TrueNAS

Move dataset to another zpool in TrueNAS

In Synology, move share folder to another volume is quite easy, can be done via UI interface. In TrueNAS, I could not find such task can be selected.

Duplicate dataset from snapshot

The workable solution is utilize the zfs command to duplicate in SSH environment, then export old pool and import new one.

First make a snapshot poolX/dataset@initial, then use following command duplicate zfs dataset snapshot to new zpool.

zfs send poolX/dataset@initial | zfs recv -F poolY/dataset

Update new dataset

Then make another snapshot poolX/dataset@incremental, then use following command update zfs dataset snapshot to new zpool.

zfs send -i initial poolX/dataset@incremental | zfs recv poolY/dataset

Activate new dataset

To make the new dataset usable, rollback snapshot needs to be performed for new dataset.

Update share

Change shared point to use new pool.

Update client

This is only required if client used server filesystem structure, such as NFS.

References

Migrate to smaller disk
*Note: pv (Pipe Viewer) command is not installed in TrueNAS by default.

Error replace hard disk in zpool in TrueNAS

Error replace hard disk in zpool in TrueNAS

Got following error when trying to replace hard disk in zpool. Reboot is required.

middlewared.service_exception.CallError: [EFAULT] Partition type 6a898cc3-1dd2-11b2-99a6-080020736631 not found on sda

Partition exists

First issue with the partition which exists in the old hard disk. Use fdisk to remove all partitions. But still could not replace.

Use force option

Then click on force check box, the replacing was started, but stopped at 15%. Tried many times, but still failed. Search google, people got same issue, but they said sudden worked.

Run partprob

Run partprob, error shows the kernel didn't know the new partition table, reboot is required.

Check partition after reboot

After reboot, checked partition table, found TrueNAS had updated partition as others, which has one 2GB swap. Then force replace hard disk in pool again, then worked

Conclution

This is TrueNAS bug, which didn't close devices in kernel before repartition hard disk, this caused partition is opened and could not reread the new partition table into kernel.

Solution

Reboot

References

Cant create Pool on TrueNAS Scale (it does work on TrueNAS Core under same Hardware)
Cant create Pool on TrueNas Scale

Clear checksum error in FreeNAS/TrueNAS

Clear checksum error in FreeNAS/TrueNAS

Identify error

Errors can be found in TrueNAS Storage section in web page, or use shell in web page, run zpool status -x command.

Sample error can be fond in following screen. There are two pools got error. The pool0 got two hard disks, first one got 154 checksum errors, second one got one data error.

  pool: pool0
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
    attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
    using 'zpool clear' or replace the device with 'zpool replace'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P
  scan: scrub repaired 0B in 00:00:02 with 0 errors on Sat Oct  2 17:39:46 2021
config:

    NAME                                            STATE     READ WRITE CKSUM
    pool0                                           ONLINE       0     0     0
      mirror-0                                      ONLINE       0     0     0
        gptid/bf410fcf-2209-11ec-b8aa-001132dbfc9c  ONLINE       0     0   154
        gptid/bfcc498a-2209-11ec-b8aa-001132dbfc9c  ONLINE       0     0     0

errors: No known data errors

  pool: pool01
 state: ONLINE
status: One or more devices has experienced an error resulting in data
    corruption.  Applications may be affected.
action: Restore the file in question if possible.  Otherwise restore the
    entire pool from backup.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-8A
config:

    NAME                                          STATE     READ WRITE CKSUM
    pool01                                        ONLINE       0     0     0
      gptid/75827da1-207a-11ec-afcf-005056a390b2  ONLINE       0     0     1
errors: List of errors unavailable: permission denied

errors: 1 data errors, use '-v' for a list

For second error, impacted file can be found using zpool status -v command

root@truenas[~]# zpool status -v pool01
  pool: pool01
 state: ONLINE
status: One or more devices has experienced an error resulting in data
        corruption.  Applications may be affected.
action: Restore the file in question if possible.  Otherwise restore the
        entire pool from backup.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-8A
  scan: scrub repaired 0B in 00:23:22 with 1 errors on Sat Oct  2 21:53:02 2021
config:

        NAME                                          STATE     READ WRITE CKSUM
        pool01                                        ONLINE       0     0     0
          gptid/75827da1-207a-11ec-afcf-005056a390b2  ONLINE       0     0     1

errors: Permanent errors have been detected in the following files:

        /mnt/pool01/download/file.1
root@truenas[~]#

Clear error

Run following command to clear the error

zpool clear <pool_name>

For the pool has data error, which has any file impacted. Delete or overwrite the file.

Then scrub the pool

zpool scrub <pool_name>

Replace disk

To replace disk, run following command, c0t0d2 is a new disk to replace c0t0d0

zpool replace c0t0d0 c0t0d2

If the disk replaced at same location, then run following command

zpool replace c0t0d0

Sort posts by last updated date in WordPress

Sort posts by last updated date in WordPress

Solution

In recent post list, the date of sorting is based on published date, so the updates will never be shown. To change this behavior, following code can be appended into functions.php to archive the sorting by last updated date.

function lmt_orderby_modified_posts( $query ) {
    if( $query->is_main_query() && !is_admin() ) {
        if ( $query->is_home() || $query->is_category() || $query->is_tag() ) {
            $query->set( 'orderby', 'modified' );
            $query->set( 'order', 'desc' );
        }
    }
}
add_action( 'pre_get_posts', 'lmt_orderby_modified_posts' );

Issue

There is an issue after changed sorting and modified post day, the archives will still be under published date, which can be comfusing.

If there is a way change permalink structure based on last updated date, then could be much simple.

References

Sort posts by modified date in the frontend
Using Permalinks
Simple Guide to Changing Your Permalinks Without Breaking Your WordPress Site

Process Listening on a Particular Port in Linux

Table of Contents

Process Listening on a Particular Port in Linux

These commands might not workable in some Unix like systems.

Using netstat

netstat -ltnp
netstat -peanut

lsof

lsof -i :80

fuser

fuser 80/tcp

ss


ss -nlp
``

## References

[3 Ways to Find Out Which Process Listening on a Particular Port](https://www.tecmint.com/find-out-which-process-listening-on-a-particular-port/)

Last updated date in WordPress

Last updated date in WordPress

There are a few methods to display last updated in WordPress

Change post date to last updated date

But default, post date is published date, if like to change it to last updated date, add additional CSS as below.

/* for post modified */
.entry-date.published { display: none; }
.updated:not(.published) { display: inline-block; }

/* for post that never been modified, theme uses .updated */
.entry-date.published.updated { display: inline-block; }

Change functions.php

function my_last_updated_date( $content ) {
    $u_time = get_the_time('U');
    $u_modified_time = get_the_modified_time('U');

    if ($u_modified_time >= $u_time + 86400) {
        $updated_date = get_the_modified_time('F jS, Y');
        $updated_time = get_the_modified_time('h:i a');
        $custom_content .= '<p class="last-updated entry-meta">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
    }

    $custom_content .= $content;
    return $custom_content;
}
add_filter( 'the_content', 'my_last_updated_date' );

Change template-tags.php

This is the PHP way to modify the code to display dates.

References

How to replace published date?